标签:docker docker制作tar docker基于运行的容器制作镜像
镜像构建:
docker commit 【option】
-a 指明作者
-p 暂停容器再建立镜像
[root@vichost ~]# docker commit -p -a "vicliaoxz <1083904509@qq.com>" centos2
sha256:ead743182b50ba021d5eee144aad229cbcf093f6796363b11e366f6117a62fab
[root@vichost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> ead743182b50 About a minute ago 302 MB
[root@vichost ~]# docker run -it --name c-net-tools ead743182b50
[root@ff3b674ffa51 /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.4 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:acff:fe11:4 prefixlen 64 scopeid 0x20<link>
给镜像添加标签
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
[root@vichost ~]# docker tag ead743182b50(ID) vicdockerhub(用户名)/centos(基础镜像):net-tools(标签)
[root@vichost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vicdockerhub/centos net-tools ead743182b50 21 minutes ago 302 MB
[root@vichost ~]# docker login -u vicdockerhub
Password:
Login Succeeded
[root@vichost ~]# docker push vicdockerhub/centos:net-tools
The push refers to a repository [docker.io/vicdockerhub/centos]
3.2.上传到私有仓库:docker tag vicdockerhub/centos:net-tools myregistry.liaoxz.xin:5000/vicdockerhub/centos:net-tools
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Options:
-o, --output string Write to a file, instead of STDOUT
[root@vichost ~]# docker save vicdockerhub/centos:net-tools -o centos-net-tools.tar
[root@vichost ~]# ls
centos-net-tools.tar
5. 外部tar包导入镜像
docker load
docker load -i 指定镜像tar包
[root@vichost ~]# docker load -i centos-net-tools.tar
Loaded image: vicdockerhub/centos:net-tools
[root@vichost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myregistry.liaoxz.xin:5000/vicdockerhub/centos net-tools ead743182b50 51 minutes ago 302 MB
vicdockerhub/centos net-tools ead743182b50 51 minutes ago 302 MB
标签:docker docker制作tar docker基于运行的容器制作镜像
原文地址:http://blog.51cto.com/liaoxz/2104319