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。