安装
Uninstall old versions
[root@docker-daemon ~]# yum remove docker docker-common docker-selinux docker-engine
Install required packages.
[root@docker-daemon ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@docker-daemon ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@docker-daemon ~]# yum-config-manager --enable docker-ce-edge
Install Docker
[root@docker-daemon ~]# yum install docker-ce
Start Docker
[root@docker-daemon ~]# systemctl enable docker
[root@docker-daemon ~]# systemctl start docker
测试docker是否正常运行
[root@docker-daemon ~]# docker run hello-worldr
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
Hello from Docker!
This message shows that your installation appears to be working correctly.
docker镜像加速器
我们使用docker的第一步,应该获取一个官方的镜像。但是因为网络原因,我们下载一个300M的镜像需要很长的时间,甚至下载失败。因为这个原因,阿里云容器Hub服务提供了官方的镜像站点加速官方镜像的下载速度。
镜像加速器的地址从容器Hub控制台上获取,左侧的加速器帮助页面就会显示为你独立分配的加速地址。
例如:
公网Mirror:[系统分配前缀].mirror.aliyuncs.com
CentOS7的配置方式略微复杂,需要先将默认的配置文件复制出来/lib/systemd/system/docker.service
-> etc/systemd/system/docker.service
,然后再将加速器地址添加到配置文件的启动命令,重启Docker就可以了。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
[root@docker-daemon ~]# systemctl daemon-reload
[root@docker-daemon ~]# systemctl restart docker
验证:docker
Ref: https://yq.aliyun.com/articles/29941
网友评论