Docker 镜像的导入和导出

镜像的导入和导出

export 和improt


[[email protected]#localhost docker]# docker run -ti  ubuntu:update /bin/bash
[email protected]d:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  update.txt  usr  var

[[email protected]#localhost docker]#
[[email protected]#localhost docker]# docker ps -a
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                        PORTS                                   NAMES
cbe3cb7799ed        ubuntu:update                  "/bin/bash"              47 seconds ago      Exited (1) 6 seconds ago                                              adoring_kare
812a997f614a        ubuntu:14.04                   "/bin/bash"              16 minutes ago      Exited (0) 8 minutes ago                                              zealous_euler
69304dea46c7        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (127) 53 minutes ago                                           competent_minsky
67ba866e21b0        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (137) 2 hours ago                                              hungry_hoover
2a3d08a0a2ff        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        2 hours ago         Exited (137) 2 hours ago                                              nervous_wozniak
6db49540be99        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        2 hours ago         Exited (255) 2 hours ago      22/tcp, 443/tcp, 0.0.0.0:3000->80/tcp   romantic_elion
b08a6d6ed716        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (255) 2 hours ago      22/tcp, 443/tcp, 0.0.0.0:8080->80/tcp   competent_brahmagupta
33fd0b1ebd27        gitlab/gitlab-ce:latest        "/assets/wrapper"        3 hours ago         Exited (127) 2 hours ago                                              loving_brattain
6f53620a930c        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        3 hours ago         Exited (127) 2 hours ago                                              brave_galileo
88df78f77c4e        ubuntu:14.04                   "sleep 360"              4 days ago          Exited (137) 4 days ago                                               testcopy
81a879a36bd3        wordpress                      "docker-entrypoint..."   4 days ago          Exited (0) 4 days ago                                                 wordpress
a57a3cc492b7        mysql                          "docker-entrypoint..."   4 days ago          Exited (0) 4 days ago                                                 mysqlwp

# 将镜像导出到文件
[[email protected]#localhost docker]# docker export cbe3cb7799ed > update.tar

# 创建一个新静像从基于导出的文件
[[email protected]#localhost /]# docker import - update < update.tar
sha256:fd00d520a43eb5dc6cca8717fe0ca04cfdc53b02cad2fb5b50d877b8e6d6c3bc
[[email protected]#localhost /]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
update                      latest              fd00d520a43e        13 seconds ago      165 MB
ubuntu                      update              317f10258460        11 minutes ago      188 MB
twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
mysql                       latest              9546ca122d3a        8 days ago          407 MB
wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB

save 和load

(像当与镜像的备份和恢复)

# update是一个已经存在的镜像
[[email protected]#localhost /]# docker save -o update1.tar update
[[email protected]#localhost /]# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  update1.tar  update.tar  usr  var
[[email protected]#localhost /]# du -sh update1.tar
166M    update1.tar

# 删除update镜像
[[email protected]#localhost /]# docker rmi update
Untagged: update:latest
Deleted: sha256:fd00d520a43eb5dc6cca8717fe0ca04cfdc53b02cad2fb5b50d877b8e6d6c3bc
Deleted: sha256:14cc8cd7b783152682835346e5fe90860a9feeb684866688692285319d4e97ad

[[email protected]#localhost /]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
ubuntu                      update              317f10258460        16 minutes ago      188 MB
twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
mysql                       latest              9546ca122d3a        8 days ago          407 MB
wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB

#导入镜像
[[email protected]#localhost /]# docker load < update1.tar
14cc8cd7b783: Loading layer [==================================================>] 173.8 MB/173.8 MB
Loaded image: update:latest
[[email protected]#localhost /]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
update                      latest              fd00d520a43e        6 minutes ago       165 MB
ubuntu                      update              317f10258460        17 minutes ago      188 MB
twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
mysql                       latest              9546ca122d3a        8 days ago          407 MB
wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB
[[email protected]#localhost /]# 

原文地址:https://www.cnblogs.com/Presley-lpc/p/9390136.html

时间: 2024-11-05 23:25:10

Docker 镜像的导入和导出的相关文章

docker镜像文件导入与导出

工作中经常需要拉取一些国外的镜像,但是网络限制等原因在公司拉取很慢,所以我习惯用亚马逊服务器拉取镜像,导出后下载到本地再导入开发环境 1. 查看镜像id sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/calico/node v1.0.1 c70511a49fa1 6 weeks ago 257 MB hello-world latest 48b5124b2768 2 months ago 1.84 kB quay.

Docker 镜像-管理-导入-导出

目录 Docker 镜像基本概念 Docker 镜像加速 Docker 镜像 常用命令 Docker 镜像的创建和导出导入 Docker 镜像基本概念 我们使用的容器都是基于镜像的,镜像是由多层组成的,容器是在镜像上面添加了一个读写层.镜像一般储存在 /var/lib/docker/image/. 多个容器是引用的同一个 镜像,容器不会更改镜像的内容,而是创建一个可写层,并将数据保存在 /var/lib/docker/containers 中. Docker 镜像加速 当我们在使用 Docker

Docker镜像的导入导出

导入/导出命令介绍 导入/导出的功能主要用于Docker镜像的导入导出,用于迁移.备份.升级等场景,或者为隔离且没有私有镜像仓库环境添加docker镜像. 导入/导出的命令主要有下面几个:export.import.save.load,可以分为2组: save和load export和import 下面分别看看他们的用法和区别 save和load 命令用法 [email protected] -> ~/manifests$ docker save --help Usage: docker sav

Docker 容器的导入和导出操作

导出容器 导出容器是指 导出一个已经创建的容器到一个文件,不管此时这个容器是否处于运行状态,可以使用docker export 命令,该命令格式为 docker export CONTAINER. 查看所有容器如下: # docker ps -a CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS                          PORTS       

docker镜像容器导入导出

记录一下,省的以后自己老忘. ubuntu-14.04-x86_64.tar.gz是下载的模板文件,导入模板文件示例如下 [email protected]:~# ll ubuntu-14.04-x86_64.tar.gz  -rw-r--r-- 1 root root 154056446 May 17 10:04 ubuntu-14.04-x86_64.tar.gz [email protected]:~# cat ubuntu-14.04-x86_64.tar.gz | docker imp

Docker容器的导入和导出&amp;存储和加载

保存镜像文件或容器作为一个压缩的文件,和别人进行共享.导出一个容器作为一个tar文件. [[email protected] ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8c892f17fc59 ubuntu:14.04 "/bin/bash" 6 minutes ago Exited (0) 5 minutes ago adoring_ardinghelli 90d654f31d93 u

Docker镜像批量导入

作用 主要目的用于批量镜像导入; 1.支持传参数导入 实例: sh import.sh "pause_3.1.tar etcd_3.3.10.tar" 注意:多个tar文件使用空格分隔; 2.支持脚本定义导入镜像名称 实例: vi import.sh STATE="ImgName1 ImgName2 ImgName3 ...." sh import.s 3.支持指定目录导入镜像 实例: vi import.sh TARDIR="/usr/local/bak

Docker 镜像批量备份(导出)

脚本作用 1.批量导出Docker Images;2.部分导出,通过指定Docker Images ID 到脚本"LIST"变量 运行实例 #导出全部的镜像: sh ExportImg.sh #导出部分镜像 LIST=" d235b 201c7a 201c7a" sh ExportImg.sh 注意:LIST赋值Docker Images ID ,多个镜像ID通过空格隔离:执行脚本是只会导出定义ID的镜像: 镜像还原(任选一种) docke load --input

docker images 保存导入导出、容器导入导出

Docker:镜像操作和容器操作 镜像操作 列出镜像: $ sudo docker images REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE hello-world         latest              0a6ba66e537a        4 weeks ago         960 B 获取镜像: docker系统镜像可以从任意一