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
相关推荐
hxdcxy2 小时前
中间件部署
运维·服务器
李少兄5 小时前
CentOS系统下前后端项目部署攻略
linux·运维·centos
咚咚?5 小时前
基于gitlab 构建CICD发布到K8S 平台
容器·kubernetes·gitlab
Two_brushes.7 小时前
【Linux】线程机制深度实践:创建、等待、互斥与同步
linux·运维·服务器·多线程
尘土哥8 小时前
Docker 快速上手
docker·容器·eureka
设计师小聂!9 小时前
Linux系统中部署Redis详解
linux·运维·数据库·redis
广州山泉婚姻9 小时前
Docker从环境配置到应用上云的极简路径
docker
努力做小白10 小时前
Linux驱动11 --- buildroot&杂项驱动开发方法
linux·运维·驱动开发·单片机·嵌入式硬件
Sally璐璐11 小时前
Memcache核心技术解析与实战应用
运维·wpf·memcached
哈哈浩丶11 小时前
Linux驱动开发1:设备驱动模块加载与卸载
linux·运维·驱动开发