CentOS离线安装docker

  • CentOS版本:7.9
  • docker版本:18.06.3

前言

说是离线安装,还是要先在线下载安装包。docker官网提供离线安装的二进制包。

步骤

  1. 官网下载安装包。链接:https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
  2. 解压安装包,将安装包内的二进制程序挪到/usr/local/bin目录。
  3. 建立docker数据存放目录:mkdir -p /home/data/docker
  4. 创建docker服务文件:vim /usr/lib/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/local/bin/dockerd --data-root /home/data/docker

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
  1. 配置生效:
systemctl daemon-reload
systemctl start docker
systemctl enable docker

CentOS离线安装docker

上一篇:Keepalived 主备


下一篇:yield