readhalt7.4 安裝 docker

AKA-TanNaWen發表於2019-11-12
Linux系統下docker安裝

1.下載docker檔案

cd /opt/
wget https://download.docker.com/linux/static/s...

2.解壓檔案

tar -xvf docker-18.06.1-ce.tgz

3.將解壓出來的docker檔案內容移動到 /usr/bin/目錄下

cp docker/* /usr/bin/

4.將docker註冊為服務

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

5.啟動

chmod +x /etc/systemd/system/docker.service #新增檔案許可權並啟動docker
systemctl daemon-reload #重新載入配置檔案
systemctl start docker #啟動Docker
systemctl enable docker.service #設定開機自啟

systemctl status docker #檢視Docker狀態
docker -v #檢視Docker版本

本作品採用《CC 協議》,轉載必須註明作者和本文連結