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
相关推荐
星宸追风4 分钟前
Ubuntu更换Home目录所在硬盘的过程
linux·运维·ubuntu
制造数字化方案研究院18 分钟前
59页|PPT|华为集成服务交付ISD业务变革总体方案:业务规则、流程、IT、组织及度量“四位一体”的管理体系
运维·华为
杨浦老苏29 分钟前
Docker端口映射查看工具Dockpeek
网络·docker·群晖
热爱生活的猴子29 分钟前
Poetry 在 Linux 和 Windows 系统中的安装步骤
linux·运维·windows
渲吧-云渲染1 小时前
云渲染时,电脑能关机吗?关键阶段操作指南
运维·服务器·电脑
m0_694845571 小时前
服务器需要备案吗?在哪些地区需要备案?
linux·运维·服务器·云计算
小眼睛FPGA1 小时前
【RK3568+PG2L50H开发板实验例程】Linux部分/FPGA dma_memcpy_demo 读写案例
linux·运维·科技·ai·fpga开发·gpu算力
别骂我h2 小时前
Kubernetes服务发布基础
云原生·容器·kubernetes
weixin_399380693 小时前
k8s一键部署tongweb企业版7049m6(by why+lqw)
java·linux·运维·服务器·云原生·容器·kubernetes
阿巴~阿巴~3 小时前
Linux基本命令篇 —— uname命令
linux·运维·服务器