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
相关推荐
SummerGao.4 分钟前
Centos 7 安装达梦数据库
linux·运维·centos·达梦
Macle_Chen5 分钟前
Xcode16.1使用MonkeyDev运行Tiktok报错分析
linux·运维·服务器·ios
三天不学习1 小时前
Windows电脑 打开 Docker Desktop 提示的“Virtual Machine Platform not enabled”的问题解决
运维·docker·容器
川石课堂软件测试2 小时前
涨薪技术|Kubernetes(k8s)之Pod端口设置及资源配额
功能测试·云原生·容器·kubernetes·单元测试
晓夜残歌4 小时前
安全基线-rm命令防护
运维·服务器·前端·chrome·安全·ubuntu
leeezp7 小时前
配置固定ip绕过ip限制
运维·网络协议
遇见火星9 小时前
docker-compose 快速搭建日志平台
linux·运维·centos
.m9 小时前
Linux怎样源码安装Nginx
linux·运维·nginx
weixin_433431449 小时前
centos【rockylinux】安装【supervisor】的注意事项【完整版】
linux·运维·centos
suzhou_speeder9 小时前
以太联—Intellinet 562133 6端口PoE++交换机:为多场景网络升级赋能
运维·网络·交换机·poe·poe交换机