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

相关推荐
jane_xing1 小时前
Next.js + SQLite 项目 Docker 生产环境部署方案
javascript·docker·sqlite
树下一少年1 小时前
ansible+docker+docker-compose快速部署4节点高可用minio集群
docker·容器·ansible·docker-compose·minio集群
曼岛_6 小时前
CentOS 7 强制升级Docker 24.x终极指南(解决MySQL8镜像兼容性问题)
linux·docker·centos
xiao智6 小时前
剖析 Docker Swarm 操作对容器端口影响
docker
葟雪儿7 小时前
Docker常用命令
linux·服务器·spring cloud·docker·微服务·容器
爬台阶的蚂蚁9 小时前
搭建docker registry私服,并且支持https推送
docker·容器·https
晴空๓11 小时前
在CentOS上安装Docker需要注意的事项
linux·docker·centos
穷儒公羊12 小时前
第一部分——Docker篇 第一章 Docker容器
运维·docker·云原生·容器
飞猪~12 小时前
docker相关命令
运维·docker·容器
三阶码叟1 天前
centos7 yum install docker 安装错误
运维·docker·容器