Linux-Centos 如何安装Docker(纯干货无废话)

1、下载docker

下载地址:https://download.docker.com/linux/static/stable/x86_64/
在这里插入图片描述
本篇以docker-18.06.3-ce.tgz为例

2、上传至服务器指定路径后解压安装文件

tar -zxvf docker-18.06.3-ce.tgz

3、将解压后的文件夹复制到指定目录(随意)

cp ./docker/* /usr/bin

4、创建docker.service文件

cd /etc/systemd/system/
touch docker.service

5、编辑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 --selinux-enabled=false --insecure-registry=192.168.212.15
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

切记检查复制过去后文本的完整性,很多情况下头部会丢失几个字符,导致失败!

6、添加可执行权限

chmod +x docker.service

7、加载docker.service

systemctl daemon-reload

8、启动docker

systemctl start docker

9、查看docker

systemctl status docker

10、设置开机自启

systemctl enable docker.service

恭喜你已经安装好了!

猜你喜欢

转载自blog.csdn.net/DDDHL7/article/details/131718428
今日推荐