linux离线安装docker并启动

linux离线安装docker并启动

  1. 解压并移动到指定目录
bash 复制代码
# 查看压缩包内容(确认包含 docker/dockerd 等二进制文件)
tar -tzf docker-24.0.6.tgz
sudo cp /docker/* /usr/local/bin/
  1. 验证是否复制成功
bash 复制代码
# 验证二进制文件是否复制成功
ls -l /usr/local/bin/docker*  # 应看到 docker、dockerd、docker-proxy 等文件
  1. 配置docker所需的文件,其中ip地址和路径使用自己的
bash 复制代码
sudo vim /etc/systemd/system/docker.service
bash 复制代码
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[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/local/bin/docker --selinux-enabled=false --insecure-registry=192.168.0.2
ExecReload=/bin/kill -s HUP $MAINPID
# 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
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# 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
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
  1. 配置 containerd文件
bash 复制代码
sudo vim /etc/systemd/system/containerd.service
bash 复制代码
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Restart=always
RestartSec=5
Delegate=yes
KillMode=process
OOMScoreAdjust=-999
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity

[Install]
WantedBy=multi-user.target
  1. 创建这些东西
bash 复制代码
# 创建 Docker 数据目录(默认 /var/lib/docker,可自定义)
sudo mkdir -p /var/lib/docker
sudo mkdir -p /run/containerd
  1. 设置权限
bash 复制代码
# 赋予二进制文件执行权限	
sudo chmod +x /usr/local/bin/docker* /usr/local/bin/containerd* /usr/local/bin/runc

chmod 777 /etc/systemd/system/docker.service
  1. 准备启动
bash 复制代码
# 重新加载 systemd 配置
sudo systemctl daemon-reload

# 启动 containerd(先确保依赖正常)
sudo systemctl start containerd

# 启动 Docker
sudo systemctl start docker

# 检查 Docker 状态
sudo systemctl status docker
相关推荐
拾光Ծ几秒前
【Linux网络】网络通信实战:UDP & TCP Socket编程实现Echo Server
linux·网络·网络协议·tcp/ip·udp·线程池
一叶龙洲11 小时前
wslg打开Ubuntu24.04默认打开图形界面
linux·服务器·数据库·ubuntu
敖行客 Allthinker13 小时前
Parallels Ubuntu虚拟机项目如何让手机访问?完整解决方案
linux·运维·ubuntu
BullSmall14 小时前
Anolis OS 8.10 完整安装 Docker CE(生产可用,解决 podman 冲突)
docker·容器·podman
keyipatience14 小时前
线程栈与TLS和线程互斥
java·linux·服务器·开发语言·ubuntu
j7~14 小时前
【Linux】二十二.《Linux 信号机制完全指南:表示、捕捉与处理》
linux·信号处理·volatile·可入重函数·保存信号
观山岳五楼15 小时前
Ubuntu 24 怎么使用Ubuntu 20 的镜像源
linux·运维·ubuntu
m0_7156467616 小时前
20260720
linux·arm
寒晓星16 小时前
[linux]线程及多线程
linux·运维
辰痕~16 小时前
物理机装Linux操作系统(Ubuntu为例)
linux·ubuntu