简述
参考官方链接:https://docs.docker.com/engine/install/binaries/
操作系统版本:CentOS7以上
安装版本:18.06.3-ce
安装方式:二进制安装
官网下载地址:https://download.docker.com/linux/static/stable/x86_64/
安装
curl -O https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
tar -xf docker-18.06.3-ce.tgz
cp docker/* /usr/bin/
配置:
docker引擎默认工作目录/var/lib/docker,可以通过 --data-root指定工作目录
使用systemd引导启动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
#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 --data-root /data/docker
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
EOF