Loading

离线部署docker和docker-compose

内网环境

下载

根据不同平台, 找到对应路径下载离线二进制包

https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-20.10.17.tgz
https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-linux-x86_64

上传到服务器解压安装

tar xf docker-20.10.17.tgz -C /usr/local/bin/
cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

配置docker服务

# 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/local/bin/dockerd --default-ulimit nofile=65535:65535
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
# 配置文件, 根据需要调整
# mkdir /etc/docker
# vi /etc/docker/daemon.json
{
 "data-root": "/var/lib/docker", 
 "live-restore": true, 
 "log-driver": "json-file", 
 "log-opts": {
  "max-file": "3", 
  "max-size": "10m"
 }, 
 "registry-mirrors": [
  "https://hub-mirror.c.163.com"
 ]
}

启动

systemctl daemon-reload
systemctl enable docker
systemctl start docker
posted @ 2022-06-13 13:03  后边跟上。  阅读(270)  评论(0编辑  收藏  举报