docker commit通過容器生成映象保留歷史
阿新 • • 發佈:2018-12-26
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
clearlinux latest 32685d114002 7 days ago 62.5MB
busybox latest 6ad733544a63 7 days ago 1.13MB
alpine latest 053cde6e8953 7 days ago 3.96MB
[ [email protected] ~]# docker run -itd --name b1 busybox
4222dcde8b4147c2b94ed7c4216fabb5821cbe2b773dad4a848af1067db56e66
[[email protected] ~]# docker run -itd --name b2 busybox
b217c4f143a87e3d8a92396ee1576554e5b568633a516c3cbda9a9922e57911f
[[email protected] ~]# docker run -itd --name b3 busybox
d10967906d42fe2bbe39ebe30bf8fde9d6b9d0823eb317bb3536122f152d0c5c
[ [email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d10967906d42 busybox "sh" 15 seconds ago Up 13 seconds b3
b217c4f143a8 busybox "sh" 36 seconds ago Up 23 seconds b2
4222dcde8b41 busybox "sh" 2 minutes ago Up 2 minutes b1
e84a746ea040 busybox "sh" 12 hours ago Exited (137) 11 hours ago box3
9c1578a50f0b busybox "sh" 12 hours ago Exited (137) 11 hours ago box2
4ca3d293206c busybox "sh" 12 hours ago Exited (0) 12 hours ago box1
[ [email protected] ~]# docker pause b2
b2
[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d10967906d42 busybox "sh" 3 minutes ago Up 3 minutes b3
b217c4f143a8 busybox "sh" 3 minutes ago Up 3 minutes (Paused) b2
4222dcde8b41 busybox "sh" 5 minutes ago Up 5 minutes b1
e84a746ea040 busybox "sh" 12 hours ago Exited (137) 11 hours ago box3
9c1578a50f0b busybox "sh" 12 hours ago Exited (137) 11 hours ago box2
4ca3d293206c busybox "sh" 12 hours ago Exited (0) 12 hours ago box1
[[email protected] ~]# docker attach d1
/ # ls
bin dev etc home proc root sys tmp usr var
/ # mkdir d1
/ # ls
bin d1 dev etc home proc root sys tmp usr var
/ # read escape sequence
[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d10967906d42 busybox "sh" 6 minutes ago Up 5 minutes b3
b217c4f143a8 busybox "sh" 6 minutes ago Up 6 minutes (Paused) b2
4222dcde8b41 busybox "sh" 8 minutes ago Up 7 minutes b1
e84a746ea040 busybox "sh" 12 hours ago Exited (137) 11 hours ago box3
9c1578a50f0b busybox "sh" 12 hours ago Exited (137) 11 hours ago box2
4ca3d293206c busybox "sh" 12 hours ago Exited (0) 12 hours ago box1
[[email protected] ~]# docker commit d1 b3d1
sha256:5b5db5fd008dc0b9044069b97c9f264ebaec0c21179b66b9c5e0a2fcf5f7cb5c
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
b3d1 latest 5b5db5fd008d 13 seconds ago 1.13MB
clearlinux latest 32685d114002 7 days ago 62.5MB
busybox latest 6ad733544a63 7 days ago 1.13MB
alpine latest 053cde6e8953 7 days ago 3.96MB
[[email protected] ~]# docker commit d1 b2b2
sha256:54a285363a1971c9395f051edb227e565c953207d1ca3cef61a5d7087e97cbe0
[[email protected] ~]# docker commit b2 b2b2
sha256:0da62b0d6e5401c9ec3ab8fe8dae1f98ad8115cf997ac8117a4cbce1a2552393
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
b2b2 latest 0da62b0d6e54 10 seconds ago 1.13MB
<none> <none> 54a285363a19 29 seconds ago 1.13MB
b3d1 latest 5b5db5fd008d About a minute ago 1.13MB
clearlinux latest 32685d114002 7 days ago 62.5MB
busybox latest 6ad733544a63 7 days ago 1.13MB
alpine latest 053cde6e8953 7 days ago 3.96MB
[[email protected] ~]# docker commit box1 box14c
sha256:c2516b7eee38b3df62b032a4a17cbbb1ba182141de3a99e92bef6a7e716eb1d4
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
box14c latest c2516b7eee38 4 seconds ago 1.13MB
b2b2 latest 0da62b0d6e54 About a minute ago 1.13MB
<none> <none> 54a285363a19 About a minute ago 1.13MB
b3d1 latest 5b5db5fd008d About a minute ago 1.13MB
clearlinux latest 32685d114002 7 days ago 62.5MB
busybox latest 6ad733544a63 7 days ago 1.13MB
alpine latest 053cde6e8953 7 days ago 3.96MB
[[email protected] ~]# docker run -itd --name b3d1container 5b
c94d5754daf05ec0c879012d6ef21f11b65b020b9bf6f55eb49d0080006034e2
[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c94d5754daf0 5b "sh" 15 seconds ago Up 11 seconds b3d1container
d10967906d42 busybox "sh" 12 minutes ago Up 12 minutes b3
b217c4f143a8 busybox "sh" 12 minutes ago Up 12 minutes (Paused) b2
4222dcde8b41 busybox "sh" 14 minutes ago Up 14 minutes b1
e84a746ea040 busybox "sh" 12 hours ago Exited (137) 12 hours ago box3
9c1578a50f0b busybox "sh" 12 hours ago Exited (137) 12 hours ago box2
4ca3d293206c busybox "sh" 12 hours ago Exited (0) 12 hours ago box1
[[email protected] ~]# docker run -itd --name b2b2container 0d
ba68efdf02b633e2b92c3b9d202a61279d03b70c21487a1fcef153a634335b24
[[email protected] ~]# docker run -itd --name box14ccontainer c25
afc95973cf428b6ea7bd3f0e1017885bddb846e2312aec7f9fcbee5a38291e5e
[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afc95973cf42 c25 "sh" 15 seconds ago Up 14 seconds box14ccontainer
ba68efdf02b6 0d "sh" 47 seconds ago Up 46 seconds b2b2container
c94d5754daf0 5b "sh" 2 minutes ago Up 2 minutes b3d1container
d10967906d42 busybox "sh" 14 minutes ago Up 14 minutes b3
b217c4f143a8 busybox "sh" 14 minutes ago Up 14 minutes (Paused) b2
4222dcde8b41 busybox "sh" 16 minutes ago Up 16 minutes b1
e84a746ea040 busybox "sh" 12 hours ago Exited (137) 12 hours ago box3
9c1578a50f0b busybox "sh" 12 hours ago Exited (137) 12 hours ago box2
4ca3d293206c busybox "sh" 12 hours ago Exited (0) 12 hours ago box1
[[email protected] ~]# docker attach c9
/ # ls
bin d1 dev etc home proc root sys tmp usr var
/ # read escape sequence
[[email protected] ~]# docker attach ba
/ # ls
bin dev etc home proc root sys tmp usr var