Docker import命令

本文将介绍Docker import命令,该命令使用 docker save 命令导出的 tar.gz 归档文件创建镜像。

docker import 命令从 docker save 归档 tag.gz 文件中创建镜像。帮助信息如下:

[root@localhost ~]# docker import --help

Usage:  docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]

Import the contents from a tarball to create a filesystem image

Options:
  -c, --change list      Apply Dockerfile instruction to the created image
  -m, --message string   Set commit message for imported image

其中:

  • -c  应用docker 指令创建镜像;

  • -m  提交时的说明文字;

实例:首先使用“docker images”查看我们拥有哪些镜像。

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              4c108a37151f        4 weeks ago         64.2MB
centos              6.7                 9f1de3c6ad53        4 months ago        191MB
centos              latest              9f38484d220f        4 months ago        202MB

使用已经导出的 ubuntu.tar.gz 创建“ubuntu”镜像,注意:这里我们没有指定TAG,tag为<none>,如下:

[root@localhost ~]# docker import ubuntu.tar.gz ubuntu
sha256:db421afca7de0826d1d1e6c79c1f26f8ae50ab38cfd28a8e7bced10c619b513a
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              db421afca7de        15 seconds ago      143MB
ubuntu              <none>              4c108a37151f        4 weeks ago         64.2MB
centos              6.7                 9f1de3c6ad53        4 months ago        191MB
centos              latest              9f38484d220f        4 months ago        202MB

我们也可以给新创建的镜像指定TAG,如下:

[root@localhost ~]# docker import ubuntu.tar.gz ubuntu:v15.10
sha256:4ef8461769e341bc822ebe5503dba036d17dae2cb61b2a5ec6139c9555599ad6
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
ubuntu              v15.10              4ef8461769e3        7 seconds ago        143MB
ubuntu              latest              db421afca7de        About a minute ago   143MB
ubuntu              <none>              4c108a37151f        4 weeks ago          64.2MB
centos              6.7                 9f1de3c6ad53        4 months ago         191MB
centos              latest              9f38484d220f        4 months ago         202MB

上面我们创建了一个“ubuntu:v15.10”的镜像,TAG为v15.10。

业精于勤,荒于嬉。——韩愈《进学解》
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号