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

相关推荐
lightningyang7 小时前
DVWA 在 openEuler 系统的安装部署
docker·渗透测试·openeuler·dvwa·天枢一体化虚拟仿真靶场平台
Ha_To11 小时前
2026.1.28 docker安装
运维·docker·容器
北极熊~~11 小时前
emqx持久化 Docker 容器中生成的数据并打包新镜像,迁移至新机器运行
运维·docker·容器
tomiatomia12 小时前
MinIO docker 部署使用的几个坑
运维·docker·容器
杨浦老苏14 小时前
Docker方式安装你的私人AI电脑助手Moltbot
人工智能·docker·ai·群晖
x70x8014 小时前
# Docker 搭建 MySQL 8 主从复制(踩坑实录 + 完整验证)
mysql·docker·容器
qq_3168377514 小时前
docker 运行 cn_clip
运维·docker·容器
木卫二号Coding15 小时前
Docker-构建自己的Web-Linux系统-Ubuntu:22.04
linux·前端·docker
春日见15 小时前
win11 分屏设置
java·开发语言·驱动开发·docker·单例模式·计算机外设
岳来16 小时前
网络小白理解容器网络endpointid
网络·docker·endpoint