ubuntu20.04离线安装docker和docker-compose

下载docker离线包

https://download.docker.com/linux/static/stable/x86_64/

解压

bash 复制代码
tar -zxvf docker-27.1.0.tgz

将docker二进制文件复制到/usr/bin/

bash 复制代码
cp docker/* /usr/bin/

添加服务文件

bash 复制代码
vim /usr/local/lib/systemd/system/docker.service
bash 复制代码
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service

[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 fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# 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

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# 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
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target
bash 复制代码
sudo vim vim /usr/local/lib/systemd/system/docker.socket
bash 复制代码
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target
bash 复制代码
vim /usr/local/lib/systemd/system/containerd.service
bash 复制代码
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

更改镜像存储目录:

bash 复制代码
sudo vim /etc/docker/daemon.json
bash 复制代码
{
  "data-root": "/mnt/docker"
}

启动验证

bash 复制代码
groupadd docker	#添加docker组,否则docker.socket启动会报错
systemctl start containerd.service && systemctl enable containerd.service
systemctl start docker.socket && systemctl enable docker.socket
systemctl start docker.service && systemctl enable docker.service
docker info		#输出结果正常代表安装成功

下载docker-compose离线安装包

https://github.com/docker/compose/releases/tag/v2.29.3

安装

bash 复制代码
mv docker-compose-linux-x86_64 /usr/bin/
mv /usr/bin/docker-compose-linux-x86_64 /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
相关推荐
夸克App4 分钟前
实现营销投放全流程自动化 超级汇川推出信息流智能投放产品“AI智投“
运维·人工智能·自动化
Rainbond云原生7 分钟前
83k Star!n8n 让 AI 驱动的工作流自动化触手可及
运维·人工智能·自动化
木觞清9 分钟前
深度对比评测:n8n vs Coze(扣子) vs Dify - 自动化工作流工具全解析
运维·自动化
zru_96021 小时前
Docker 部署 Redis:快速搭建高效缓存服务
redis·缓存·docker
中云时代-防御可测试-小余1 小时前
高防IP是如何防护DDoS攻击和CC攻击的
运维·服务器·tcp/ip·安全·阿里云·ddos·宽度优先
网硕互联的小客服1 小时前
如何模拟黑客攻击(Red Teaming)以测试服务器安全性
运维·服务器
樽酒ﻬق2 小时前
Kubernetes 常用运维命令整理
运维·容器·kubernetes
wt_cs3 小时前
身份证实名认证:通往数字安全与便捷生活的钥匙
运维·服务器
zym大哥大3 小时前
Linux实现网络计数器
运维·服务器·网络
Golinie3 小时前
Docker底层原理浅析 | namespace+cgroups+文件系统
docker·容器·文件系统·cgroups·unionfs