1、uninstall old docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2、install require packages
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
3、update yum repo
sudo yum-config-manager \
--add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4、update yum cache
sudo yum makecache fast
5、install docker-ce
sudo yum install docker-ce
可能会出现的错误:
Error:
Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed此时需要安装新版containerd.io
dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
6、start docker service
sudo systemctl start docker
7、verify docker
sudo docker run hello-world
ps: 参考官方文档 v18.09
# docker镜像的默认存储路径是/var/lib/docker
# 配置文件地址 /usr/lib/systemd/system/docker.service
# 在ExecStart行加上 --graph /docker/data
# 启用docker远程连接
# 配置文件地址 /usr/lib/systemd/system/docker.service
# 在ExecStart行加上 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph /docker/data -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
# 修改配置后需要重启docker
systemctl daemon-reload
systemctl restart docker
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile
# Loaded plugins: branch, fastestmirror, langpacks
# docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable
# docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
# Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]
# 拉取github上的docker-compose
# https://github.com/docker/compose/releases?after=1.26.0-rc1
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# 赋予执行权限
chmod +x /usr/local/bin/docker-compose
# 查看版本
docker-compose --version
其他Docker链接