docker安装
1.版本
- 选择的版本是17.03.2,
- 安装包为ce和selinux,这俩即可。docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm和docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
- 下载地址为清华源
- 系统版本为CentOS-7.4
2.安装方式
-
由于需要,采用离线安装,所以需要很多依赖,具体离线依赖的安装方式,请参考我的博客
yum离线安装 -
安装所需要的依赖库之后,开始安装docker。
yum install docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
yum install docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
- 安装成功之后,修改配置文件
vim /etc/systemd/system/docker.service
- docker.service内容
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
- docker启动
chmod +x /etc/systemd/system/docker.service # 添加文件权限并启动docker
systemctl daemon-reload # 重载unit配置文件
Systemctl start docker # 启动docker
systemctl enable docker.service # 设置开机自启
- 检查
systemctl status docker # 查看docker状态
docker -v # 查看docker版本
谁不是孤身一人,翻山越岭