docker安装方式主要有两种:
1.在线yum命令安装;
2.离线安装;
一、、YUM安装步骤
1.卸载老旧版本的docker
yum remove docker docker-common container-selinux docker-selinux docker-engine
2.安装必要的一些系统工具--------此命令可能有可能失败,没事,继续下一步
yum install -y yum-utils device-mapper-persistent-data lvm2
3.添加软件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.更新yum索引
yum makecache fast
5.查看docker版本信息
yum list docker-ce --showduplicates | sort -r
6.安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
yum -y install docker-ce-[VERSION]
yum -y install docker-ce #下载最新版本的docker
yum install -y docker-ce-18.09.9 docker-ce-cli-18.09.9 #下载指定版本的docker和客户端
二、离线安装
1.下载需要安装的docker版本
地址:https://download.docker.com/linux/static/stable/x86_64/
2.上传到目标服务器并将安装包解压
tar -xvzf docker-20.10.5.tgz -C /usr/local/
3.创建数据路径
mkdir -p /data/docker
4.配置快速启动
cp /usr/local/docker/* /usr/bin
5.使用systemd风格管理
vim /etc/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd --graph=/data/docker
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $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
systemctl daemon-reload
systemctl restart docker.service
systemctl enable docker.service