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

相关推荐
天上掉下来个程小白1 小时前
Docker-07.Docker基础-数据卷挂载
运维·docker·微服务·容器
迷失蒲公英1 小时前
Docker容器中文PDF生成解决方案
docker·容器·pdf
杨浦老苏4 小时前
IMAP电子邮件归档系统Mail-Archiver
docker·群晖·邮件·email
KS、zheng9 小时前
【DOCKER】Windows Server 2016 Datacenter离线安装Docker引擎
windows·docker·容器
企鹅侠客15 小时前
2 安装 Docker 和 Jenkins:持续构建环境起步
docker·容器·jenkins·持续构建环境部署
gs801401 天前
GitLab Docker Compose 迁移后 Redis 权限问题排查与解决
redis·docker·gitlab
❀͜͡傀儡师1 天前
Docker 安装部署 OceanBase
docker·容器·oceanbase
ifanatic1 天前
[每周一更]-(第154期):Docker 底层深度剖析:掌控 CPU 与内存资源的艺术
docker
草堂春睡足1 天前
【数据迁移】Windows11 下将 Ubuntu 从 C 盘迁移到 D 盘
linux·windows·ubuntu·docker