docker 镜像导入导出的方法

目录

前言

导入、导出镜像

导出镜像

  1. 查看镜像

    shell> docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    nacos/nacos-server v2.2.1 faff56ad2ef5 16 months ago 1.17GB
    docker.elastic.co/elasticsearch/elasticsearch 7.10.0 37190fe5beea 3 years ago 774MB

  2. 导出镜像

    shell> docker save faff56ad2ef5 > docker_images_nacos_v2.2.1.tar

或者

复制代码
shell> docker save -o docker_images_nacos_v2.2.1.tar nacos/nacos-server:v2.2.1

导入镜像

  1. 导入镜像

    shell>docker load < docker_images_nacos_v2.2.1.tar

  2. 查看镜像

    shell> docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    faff56ad2ef5 16 months ago 1.17GB

  3. 重命名镜像

    shell> docker tag faff56ad2ef5 nacos:v2.2.1

  4. 再次查看镜像

    shell> docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    nacos v2.2.1 faff56ad2ef5 16 months ago 1.17GB

从容器导出,导入镜像

从容器导出

  1. 查看容器

    shell> docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME
    3530f4b0b8ed hello-world "/hello" 11 months ago Exited (0) 11 months ago strange_noether

  2. 从容器导出

    shell> docker export 3530f4b0b8ed > docker_container_hello-world.tar

导入镜像

  1. 导入镜像

    shell> docker import - new-hello-world < docker_container_hello-world.tar

  2. 查看镜像

    shell> docker images
    REPOSITORY TAG IMAGE ID CREATED SIZE
    new-hello-world latest e8705c3d6974 15 seconds ago 13.3kB

相关推荐
猫吃了源码5 小时前
k9s简介和安装
linux·docker·kubernetes
云原生指北6 小时前
Docker Sandboxes 上手:从安装到第一次跑 Agent
运维·docker·容器
ziyun6668886 小时前
Docker 容器化 Web 服务架构搭建与自动化运维项目
运维·docker·架构
骇客野人9 小时前
Docker Compose 部署多个独立 Jar 服务完整实操步骤
docker·容器·jar
云川之下11 小时前
【k8s】Docker inspect 命令
docker·容器·kubernetes
倔强的石头10612 小时前
飞牛OS部署Mtab:Docker搭建自托管书签导航并实现远程访问
运维·docker·容器
apgk11 天前
基于Canal实现mysql数据同步到消息队列(RabbitMQ/Kafka)详细操作教程
docker·kafka·rabbitmq
fatcoder1 天前
玩转Docker 06 — 容器网络
前端·后端·docker
AR_xsy1 天前
docker--资源配额 配置
运维·docker·容器
国际云,接待1 天前
Docker 容器突然退出、服务莫名重启:从 OOMKilled 到内存泄漏的生产排查手册
运维·docker·容器