Docker commit

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker run --name b1 -it busybox

/ # mkdir /data/html -p

/ # vi data/html/index.html

bin data dev etc home proc root sys tmp usr var

/ # read escape sequence

[root@node101 ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

fb101638ecd7 busybox "sh" 5 minutes ago Up 5 minutes b1

[root@node101 ~]# docker commit -p b1 yxr877431436/httpd:v0.1

sha256:a257de8b352a1cb7f42232360ccc1ae93b5149d5e0320b95b7cef9e28ec0e05e

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

yxr877431436/httpd v0.1 a257de8b352a 10 seconds ago 1.16MB

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker commit -a "yxr877431436 <[email protected]>" -c "CMD ["/bin/httpd","-f","-h","/data/html"]" -p b1 yxr877431436/httpd:v0.2

sha256:85926981997a9df16a432b74e0fa78140d1759682418ea5f8422bb3061dc0f68

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

yxr877431436/httpd v0.2 85926981997a 5 seconds ago 1.16MB

yxr877431436/httpd v0.1 a257de8b352a 2 minutes ago 1.16MB

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker run --name t1 yxr877431436/httpd:v0.2

/bin/sh: [/bin/httpd,-f,-h,/data/html]: not found

[root@node101 ~]# docker run --name t1 yxr877431436/httpd:v0.2 ^C

[root@node101 ~]# docker attach b1

/ #

/ # ls

bin data dev etc home proc root sys tmp usr var

/ # vi data/html/index.html

/ # wh

which who whoami whois

/ # which httpd

/bin/httpd

/ # read escape sequence

[root@node101 ~]# ls

anaconda-ks.cfg

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

yxr877431436/httpd v0.2 85926981997a 6 minutes ago 1.16MB

yxr877431436/httpd v0.1 a257de8b352a 9 minutes ago 1.16MB

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

fb101638ecd7 busybox "sh" 15 minutes ago Up 15 minutes b1

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

yxr877431436/httpd v0.1 a257de8b352a 10 minutes ago 1.16MB

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker commit -a "Saviorsyang <[email protected]>" -c 'CMD ["/bin/httpd","-f","-h","/data/html"]' -p b1 yxr877431436/httpd:v0.2

sha256:bf9bf96e457276b504151736b59356a9355e606840c5d978e88342f5ce0f6aa1

[root@node101 ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

yxr877431436/httpd v0.2 bf9bf96e4572 4 seconds ago 1.16MB

yxr877431436/httpd v0.1 a257de8b352a 12 minutes ago 1.16MB

nginx 1.14-alpine 14d4a58e0d2e 5 days ago 17.4MB

redis latest e1a73233e3be 12 days ago 83.4MB

nginx latest 06144b287844 12 days ago 109MB

busybox latest e1ddd7948a1c 6 weeks ago 1.16MB

quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB

[root@node101 ~]# docker run --name t1 yxr877431436/httpd:v0.2

[root@node101 ~]# docker inspect t1

[root@node101 ~]# curl 172.17.0.3

<h1>Welcome to busybox...</h1>

 

Docker Commit用于日常系统打标等工作内容。

猜你喜欢

转载自www.cnblogs.com/Saviorsyang/p/9667542.html