离线安装dokcer&离线获取docker镜像

文章目录

离线安装docker

1、下载docker 安装包

下载地址:https://download.docker.com/linux/static/stable/x86_64/

我这里下载的是docker-26.1.1.tgz ,一般我们需要下载社区版 -ce ;

复制代码
 cd /root/nestle/service/swpackage
tar -zxvf docker-26.1.1.tgz 
 cp -p docker/*  /usr/bin
vi /usr/lib/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
 systemctl status docker
 systemctl enable docker
docker -v 

2、上传docker安装包到服务器

cmd命令:

scp -r C:\Users\small\Downloads\docker-19.03.9.tgz root@192.168.10.130:/xxx/

3、解压docker-xxx.tgz

解压docker-xxx.tgz

tar -zxvf docker-19.03.9.tgz

4、解压的docker文件夹全部移动至/usr/bin目录

cp -p docker/* /usr/bin

5、将docker注册为系统服务

在/usr/lib/systemd/system/目录下,创建docker.service文件

编辑docker.service文件

vi /usr/lib/systemd/system/docker.service

复制内容到docker.service中

复制代码
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
                -H tcp://0.0.0.0:4243 \
                -H unix:///var/run/docker.sock \
                --selinux-enabled=false \
                --log-opt max-size=1g
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=on-failure
[Install]
WantedBy=multi-user.target

6、重启生效

6.1、重新加载配置文件

重新加载某个服务的配置文件,如果新安装了一个服务,归属于 systemctl 管理,要是新服务的服务程序配置文件生效,需重新加载。

systemctl daemon-reload

6.2、启动Docker服务

systemctl start docker

6.3、查看启动状态

systemctl status docker

6.4、 设置docker为开机自启

systemctl enable docker

6.5、查看docker版本

docker version

7 离线安装docker镜像

离线安装docker镜像

离线安装Docker镜像的基本步骤如下:

在有网络连接的机器上下载Docker镜像:

复制代码
docker save -o <path-for-save-image> <image-name>

例如,要保存名为ubuntu:18.04的镜像,可以执行:

复制代码
docker save -o ubuntu_1804.tar ubuntu:18.04

将生成的镜像文件(例如ubuntu_1804.tar)复制到离线的机器上。

在离线机器上加载镜像:

复制代码
docker load -i <path-to-image-file>

例如,要加载之前保存的ubuntu_1804.tar镜像,可以执行:

复制代码
docker load -i ubuntu_1804.tar

镜像现在可以在离线机器上使用了。

请确保你有权限在目标机器上运行Docker,并且Docker服务已经安装和运行。

相关推荐
Mr. Cao code1 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
Dontla1 小时前
Docker多共享网络配置策略(Docker多网络、Docker networks、Docker Compose网络、Docker网络、Docker共享网络)
网络·docker·容器
Jayin_chan2 小时前
paddlex3.0.1-ocr服务化安装部署(docker)
docker·容器·ocr
ifanatic2 小时前
[每周一更]-(第159期):Go 工程师视角:容器化技术(Docker/Kubernetes)与CI/CD流程的应用场景
docker·golang·kubernetes
感哥4 小时前
Docker镜像
docker
Dontla4 小时前
Dockerfile解析器指令(Parser Directive)指定语法版本,如:# syntax=docker/dockerfile:1
java·docker·eureka
楠神说软件测试6 小时前
Docker命令(全)
docker
LuiChun6 小时前
docker desktop更新到【4.45.0 】后,旧容器镜像都丢失了
docker·容器·dubbo
子兮曰7 小时前
🔥C盘告急!WSL磁盘暴增?三招秒清20GB+空间
前端·windows·docker
ZLRRLZ7 小时前
【Docker】Docker安装
运维·docker·容器