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

相关推荐
Dontla1 小时前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker
飞火流星0202712 小时前
docker安装etcd:docker离线安装etcd、docker在线安装etcd、etcd镜像下载、etcd配置详解、etcd常用命令、安装常见问题总结
docker·容器·etcd
magrich14 小时前
Docker usage on ubuntu
ubuntu·docker·容器
ZZDICT18 小时前
两台互通的服务器使用Docker部署一主两从MySQL8.0.35
运维·服务器·mysql·docker
程序员没睡醒19 小时前
【小白友好】Docker 入门详解:从零开始学“应用集装箱”
docker·容器·eureka
人才瘾大19 小时前
docker和k8s
docker·kubernetes