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的语莫6 分钟前
linux的root目录缓存清理
linux·运维·服务器
oMcLin8 分钟前
如何在 SUSE Linux Enterprise Server 15 上部署并优化 K3s 集群,提升轻量级容器化应用的资源利用率?
linux·运维·服务器
怣疯knight13 分钟前
Docker Desktop 4.55.0版本安装成功教程
windows·docker
L_090735 分钟前
【Linux】进程概念
linux
Ghost Face...44 分钟前
深入解析YT6801驱动模块架构
linux·运维·服务器
比奇堡派星星1 小时前
Linux 杂项设备驱动框架详解
linux·arm开发·驱动开发
东方佑1 小时前
使用Docker Compose一键部署OnlyOffice:完整指南与配置解析
运维·docker·容器
Eternity∞1 小时前
基于Linux系统vim编译器情况下的C语言学习
linux·c语言·开发语言·学习·vim
赵文宇(温玉)1 小时前
Docker的价值、特点、创新与关键技术
运维·docker·容器
芝麻馅汤圆儿1 小时前
cpu 大小核
linux·运维·centos