两种安装方式,一种是直接通过yum安装,对应的版本较低;另一种方法是下载新版本安装
1、yum安装低版本docker
[root@Server1 ~]# yum -y install docker [root@Server1 ~]# docker --version Docker version 1.13.1, build 4ef4b30/1.13.1
2、安装高版本docker
安装高版本之前,需先卸载低版本docker,可通过yum list installed查看目前已安装哪些docker组件
[root@Server1 ~]# yum list installed|grep docker docker.x86_64 2:1.13.1-108.git4ef4b30.el7.centos @extras docker-client.x86_64 2:1.13.1-108.git4ef4b30.el7.centos @extras docker-common.x86_64 2:1.13.1-108.git4ef4b30.el7.centos @extras
卸载docker、docker-client、docker-common
[root@Server1 ~]# yum remove docker*
安装最新docker。
[root@Server1 ~]# curl -sSL https://get.docker.com/ | sh [root@Server1 ~]# docker --version Docker version 19.03.6, build 369ce74a3c
若因为网络问题安装不来,则可用阿里云的来安装
curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet| sh -
3、更换docker镜像源为阿里云镜像源
编辑/etc/docker/daemon.json文件,若该文件不存在则直接创建,具体内容如下。修改后,重启docker服务
[root@Server1 ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://vccl7454.mirror.aliyuncs.com"] }
4、二进制部署docker
下载二进制包,地址在https://download.docker.com/linux/static/stable/x86_64/
具体部署示例如下所示
# 下载并解压
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz tar zxf docker-20.10.7.tgz mv docker/* /usr/bin
# 配置docker服务 cat > /usr/lib/systemd/system/docker.service << EOF [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target EOF
# 修改镜像源 mkdir /etc/docker cat > /etc/docker/daemon.json << EOF { "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"] } EOF
# 启动docker systemctl daemon-reload systemctl start docker systemctl enable docker