Centos离线安装Docker

作者 : 松哥资源 本文共1862个字,预计阅读时间需要5分钟 发布时间: 2019-11-11 共1.26K人阅读




示例标题

下载离线安装包

下载地址: https://download.docker.com/linux/static/stable/x86_64/

这里选择了 docker-19.03.12.tgz

禁用SELinux

如果不禁用的话,本人遇到过如下问题:在开启防火墙的情况下,执行systemctl start docker 卡死。 关闭防火墙后,上面的命令就能正常启动

vi /etc/selinux/config   

编辑上面的文件把SELINUX设置为disabled,重启后生效,如果不重启可以通过命令临时生效:  setenforce 0

解压

tar -zxvf 离线安装包

mv docker/* /usr/bin

编辑开机启动脚本

vi /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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
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

启动Docker

//赋予执行权限
chmod +x /etc/systemd/system/docker.service

//设置开启启动
systemctl enable docker

//启动docker
systemctl start docker

系统推荐



  • 随机毒鸡汤:有些事情,只要静下心去做,就一定会睡着。


文章来源于justsoso.fun: Centos离线安装Docker





发表回复