離線安裝docker(RedHat7.4)
1. 下載地址
2. 解壓並注冊為service
- 下載安裝
# 下載
tarball="docker-18.09.7.tgz"
wget -c https://download.docker.com/linux/static/stable/x86_64/${tarball}
# 解壓
tar -zxvf ${tarball}
# 復制到/usr/bin
cp docker/* /usr/bin
- 添加到service: vim /etc/systemd/system/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
#重載unit配置文件
systemctl daemon-reload
#啟動docker
systemctl start docker
#設置開機自啟
systemctl enable docker.service
- 檢查狀態
# 狀態
systemctl status docker
# 版本
docker -v