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
相关推荐
雾时之林1 天前
Linux---计算机网络常见面试题
linux·运维·计算机网络
10mAh1 天前
【Linux】error while loading shared libraries 怎么解决?——ldd、RPATH 与动态链接排错
java·linux·前端
承渊政道1 天前
飞牛NAS部署Immich:搭建家庭相册并实现远程访问
运维·服务器·docker·内网穿透·cpolar·nas·immich
楷哥爱开发1 天前
如何在 Windows、macOS 和 Linux 上安装 scikit-learn (sklearn)
linux·windows·macos
十年磨一剑~1 天前
CAAM不落盘存储密钥方式处理
linux·ubuntu
zhangrelay1 天前
ROS 2 Lyrical 第2章 ROS 2系统架构与核心概念
linux·笔记·学习·ubuntu·ros2
ruofu331 天前
如何让docker使用提前下载好的镜像,而不是在线拉取
java·spring cloud·docker
橘色的喵1 天前
EventPool 32-bit 带标签 CAS 池:RT-Thread 单核 + Linux 双平台无锁
linux·运维·服务器
buhuizhiyuci1 天前
【Linux 网络篇】数据的 “循环系统“:协议认识与网络传输的流程
linux·运维·服务器·网络·vscode
雾时之林1 天前
Linux------磁盘管理
linux·运维