准备工作
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
添加yum源
国内优先选择阿里源和中科大源
阿里源
sudo yum-config-manager --add-repo [http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo](http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo)
中科大源
sudo yum-config-manager \
--add-repo \
[https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo](https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo)
官方源
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#安装
sudo yum makecache fast sudo yum -y install docker-ce
更新yum包索引 yum makecache fast
1) 直接安装Docker CE (will always install the highest possible version,可能不符合你的需求)
yum install docker-ce
2) 指定版本安装 (如ocker-ce-18.09 )
yum install docker-ce-18.09.9
yum list docker-ce --showduplicates|sort –r
yum install docker-ce-17.09.0.ce
docker 自动补全
yum install -y bash-completion
echo 'source /usr/share/bash-completion/bash_completion' >> ~/.bashrc
#启动Docker
systemctl start docker
#设置开机自启动
systemctl enable docker
#镜像加速器
vi /etc/docker/daemon.json
# 加入
{ "registry-mirrors": [ "[https://dockerhub.azk8s.cn](https://dockerhub.azk8s.cn/)", "[https://hub-mirror.c.163.com](https://hub-mirror.c.163.com/)" ] }
#之后重新启动服务。
sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl stop docker
systemctl start docker
参考:
https://yeasy.gitbooks.io/docker_practice/install/centos.html