docker commit 【option】
-a 指明作者
-p 暂停容器再建立镜像
[[email protected] ~]# docker commit -p -a "vicliaoxz <[email protected]>" centos2
sha256:ead743182b50ba021d5eee144aad229cbcf093f6796363b11e366f6117a62fab
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> ead743182b50 About a minute ago 302 MB
[[email protected] ~]# docker run -it --name c-net-tools ead743182b50
[[email protected] /]# 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]
[[email protected] ~]# docker tag ead743182b50(ID) vicdockerhub(用户名)/centos(基础镜像):net-tools(标签)
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vicdockerhub/centos net-tools ead743182b50 21 minutes ago 302 MB
3.1.推送到docker-hub(需要注册一个dockerhub账号)
[[email protected] ~]# docker login -u vicdockerhub
Password:
Login Succeeded
[[email protected] ~]# 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
- 将镜像保存为tar包
docker ecport 导出为一个容器Usage: docker save [OPTIONS] IMAGE [IMAGE...] Options: -o, --output string Write to a file, instead of STDOUT
[[email protected] ~]# docker save vicdockerhub/centos:net-tools -o centos-net-tools.tar
[[email protected] ~]# ls
centos-net-tools.tar
5. 外部tar包导入镜像
docker load
docker load -i 指定镜像tar包
[[email protected] ~]# docker load -i centos-net-tools.tar
Loaded image: vicdockerhub/centos:net-tools
[[email protected] ~]# 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
原文地址:http://blog.51cto.com/liaoxz/2104319
时间: 2024-11-05 21:54:44