写文档不易,可以先行打赏哦
1.检查安装条件
Docker CE支持64位版本CentOS7,并且内核版本不低于3.10,CentOS7满足最低内核要求
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 注册为服务,内容如下
[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)设置是针对有搭建了自己私服Harbor时允许docker进行不安全的访问,否则访问将会被拒绝。
3.启动
#为 docker.service 文件添加执行权限
chmod +x /etc/systemd/system/docker.service
#重新加载配置文件
systemctl daemon-reload
#启动
systemctl start docker
#设置开机自启
systemctl enable docker.service
#查看 docker 服务状态
systemctl status docker
4.设置开机自启
#设置开机启动
systemctl enable docker.service
#查看 docker 服务状态
systemctl status docker
4.解决错误(折腾了我好几天)
image.png修改/etc/selinux/config
SELINUX=disabled
网友评论