Centos离线安装Docker
大约 3 分钟
下载离线安装包
下载地址: 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
系统推荐
- JDK命令行工具
- K8S 无感发布
- 你真的会拼接字符串吗?
- Docker笔记
- 分库分表
- 分布式事务Seata
- 分布式问题
- 免费 API 每日提供摸鱼日报,自动返回无水印图片,适用于公众号和小程序
- 批量替换文件名中的指定字符串
- raft协议
- K8S常用命令
- Linux
- 随机毒鸡汤:做题前,先想想出题者的用意,我觉得他想我死。