寫文檔不易拥坛,可以先行打賞哦
1.檢查安裝條件
Docker CE支持64位版本CentOS7恼布,并且內(nèi)核版本不低于3.10耳贬,CentOS7滿足最低內(nèi)核要求
image.png
uname -srm
2.下載docker(這里選擇v19.03.8)
https://download.docker.com/linux/static/stable/x86_64/
3.安裝
1.解壓
#解壓
tar -zxvf docker-19.03.8.tgz
#移動到bin目錄
cp docker/* /usr/bin/
2.在 /etc/systemd/system/ 目錄下新增 docker.service 文件攒射,將 docker 注冊為服務(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è)置是針對有搭建了自己私服Harbor時(shí)允許docker進(jìn)行不安全的訪問,否則訪問將會被拒絕会放。
3.啟動
#為 docker.service 文件添加執(zhí)行權(quán)限
chmod +x /etc/systemd/system/docker.service
#重新加載配置文件
systemctl daemon-reload
#啟動
systemctl start docker
#設(shè)置開機(jī)自啟
systemctl enable docker.service
#查看 docker 服務(wù)狀態(tài)
systemctl status docker
4.設(shè)置開機(jī)自啟
#設(shè)置開機(jī)啟動
systemctl enable docker.service
#查看 docker 服務(wù)狀態(tài)
systemctl status docker
4.解決錯(cuò)誤(折騰了我好幾天)
image.png
修改/etc/selinux/config
SELINUX=disabled