docker练习地址
https://labs.play-with-docker.com/
此地址登录后,可以免费使用机器用于docker的练习,每次提供4小时的时间,到期后需要重新登录
1. 查看当前系统版本
cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
2. 删除旧版本的docker
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-selinux
docker-engine-selinux
docker-engine
3.修改yum源为阿里源
#删除本地源
rm -fr /etc/yum.repos.d/*.repo
#下载阿里云源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#下载docker源
curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
#将源文件中的地址替换为清华源
sed -i 's#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo
4. 安装docker
yum install docker-ce -y
5.启动docker、设置开机启动,查看docker版本信息
#启动docker
systemctl start docker
#设置开机启动
systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
#查看docker信息,由于docker是C/S架构,只有启动docker后才能看到server相关信息
docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:07 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:19:36 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
6.添加阿里云镜像源
# 编辑配置文件/etc/docker/daemon.json
添加镜像地址到字典中
{
"registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}