CentOS7 安装 Docker

卸载掉旧版本的 Docker:

yum remove -y docker docker-client docker-client-latest docker-common \
docker-latest docker-latest-logrotate docker-logrotate \
docker-selinux docker-engine-selinux docker-engine

执行以下安装命令去安装依赖包:

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce docker-ce-cli containerd.io

启动Docker

systemctl enable docker
systemctl start docker
systemctl status docker

开放所有端口

firewall-cmd --add-port=0-65535/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

配置 Docker 镜像加速

科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://<你的ID>.mirror.aliyuncs.com
七牛云加速器:https://reg-mirror.qiniu.com

在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件):

{"registry-mirrors":["具体的镜像加速器地址"]}
比如
{
"registry-mirrors": [
"https://hub-mirror.c.163.com"
]
}

之后重新启动服务:
systemctl daemon-reload
systemctl restart docker

CentOS7 卸载 docker

systemctl stop docker
rm -rf /var/lib/docker
yum list installed | grep docker |awk '{print "yum -y remove " $1}' >> remove_docker
sh ./remove_docker