- 下載 Docker
https://download.docker.com/linux/static/stable/x86_64/ - 解壓壓縮文件
tar -zxvf docker-19.03.8.tgz
- 將解壓好的 Docker 文件復(fù)制到 /usr/bin 目錄下
cp docker/* /usr/bin/
- 在 /etc/systemd/system/ 目錄下新增 docker.service 文件勾效,將 docker 注冊(cè)為服務(wù),內(nèi)容如下
[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 --selinux-enabled=false --insecure-registry=127.0.0.1
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
此處的--insecure-registry=127.0.0.1(此處改成你私服ip)設(shè)置是針對(duì)有搭建了自己私服Harbor時(shí)允許docker進(jìn)行不安全的訪問叛甫,否則訪問將會(huì)被拒絕葵第。
- 啟動(dòng) docker
- 為 docker.service 文件添加執(zhí)行權(quán)限
chmod +x /etc/systemd/system/docker.service
- 重新加載配置文件
systemctl daemon-reload
- 啟動(dòng)
systemctl start docker
- 設(shè)置開機(jī)啟動(dòng)
systemctl enable docker.service
- 查看 docker 服務(wù)狀態(tài)
systemctl status docker