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
相关推荐
初听于你31 分钟前
IP地址与路由器地址
linux·运维·服务器·网络·tcp/ip·计算机网络·智能路由器
FJW0208141 小时前
【Linux】SElinux的管理及优化
linux·运维·服务器
坐怀不乱杯魂1 小时前
Linux - 进程控制
linux·运维·服务器
重生之绝世牛码1 小时前
Linux软件安装 —— zookeeper集群安装
大数据·linux·运维·服务器·zookeeper·软件安装
额1291 小时前
磁盘物理卷、卷组、逻辑卷管理
linux·运维·服务器
Maggie_ssss_supp1 小时前
Linux-正则表达式
linux·运维·正则表达式
重生之绝世牛码2 小时前
Linux软件安装 —— kafka集群安装(SASL密码验证)
大数据·linux·运维·服务器·分布式·kafka·软件安装
努力的小帅2 小时前
Linux_多线程(Linux入门到精通)
linux·多线程·多进程·线程同步·线程互斥·生产消费者模型
晴天¥2 小时前
操作系统由MBR->GPT,导致系统黑屏是怎么回事?
linux
王九思2 小时前
Linux cgroup 简介
linux·运维·服务器