Linux 离线安装 Docker

一、安装 docker

1. 下载 Docker 安装包

https://download.docker.com/linux/static/stable/x86_64/

2. 解压安装包

powershell 复制代码
tar -xvf docker-27.1.0.tgz
mv docker/* /usr/bin/

3. 将 docker 注册为 service 服务

powershell 复制代码
vim /etc/systemd/system/docker.service

docker.service

powershell 复制代码
[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/bin/dockerd
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

4. 启动docker

powershell 复制代码
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker

5. 查看版本号

powershell 复制代码
systemctl status docker
docker -v

6. 设置开机自启

powershell 复制代码
systemctl enable docker.service

二、镜像保存和加载

1. 保存镜像

powershell 复制代码
docker save -o 镜像保存的名字和位置 镜像名:TAG

docker save -o nginx.tar nginx:latest

2. 加载镜像

powershell 复制代码
docker load -i 镜像保存的名字和位置

docker load -i nginx.tar
相关推荐
摸鱼仙人~8 分钟前
RAG 系统中的 TOC Enhance:用“目录增强”提升检索与生成效果
linux·运维·服务器
忍冬行者11 分钟前
k8s的etcd的一键备份和故障恢复
docker·云原生·容器·kubernetes·云计算
xingzhemengyou111 分钟前
Linux dmesg 查看系统启动日志
linux
华如锦12 分钟前
一.2部署——大模型服务快速部署vLLM GPU 安装教程 (Linux)
java·linux·运维·人工智能·后端·python·vllm
Jacob程序员15 分钟前
Linux scp命令:高效远程文件传输指南
linux·运维·服务器
corpse201019 分钟前
Transparent Huge Pages(透明大页)对redis的影响
linux·redis
小二·20 分钟前
前端 DevOps 完全指南:从 Docker 容器化到 GitHub Actions 自动化部署(Vue 3 + Vite)
前端·docker·devops
Cx330❀20 分钟前
Linux进程前言:从冯诺依曼体系到操作系统的技术演进
linux·运维·服务器
阿巴~阿巴~21 分钟前
帧长、MAC与ARP:解密局域网通信的底层逻辑与工程权衡
linux·服务器·网络·网络协议·tcp/ip·架构·以太网帧
oMcLin23 分钟前
如何在 Manjaro Linux 上实现高效的 Ceph 存储集群,提升大规模文件存储的冗余性与性能?
linux·运维·ceph