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
相关推荐
chlk1231 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件1 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
小p2 天前
docker学习7:docker 容器的通信方式
docker
小p2 天前
docker学习5:提升Dockerfile水平的5个技巧
docker
小p2 天前
docker学习3:docker是怎么实现的?
docker
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行3 天前
Linux和window共享文件夹
linux