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
相关推荐
努力学习的小廉3 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
MickeyCV3 小时前
使用Docker部署MySQL&Redis容器与常见命令
redis·mysql·docker·容器·wsl·镜像
秃头菜狗3 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
棠十一3 小时前
Rabbitmq
分布式·docker·rabbitmq
jiunian_cn4 小时前
【Linux】centos软件安装
linux·运维·centos
藥瓿亭5 小时前
K8S认证|CKS题库+答案| 6. 创建 Secret
运维·ubuntu·docker·云原生·容器·kubernetes·cks
2302_809798325 小时前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器
嵌入式大圣5 小时前
Neko虚拟浏览器远程协作方案:Docker+内网穿透技术部署实践
运维·docker·容器
孔令飞5 小时前
Kubernetes 节点自动伸缩(Cluster Autoscaler)原理与实践
ai·云原生·容器·golang·kubernetes
dmy5 小时前
n8n内网快速部署
运维·人工智能·程序员