How to create image from running docker container and share that image to other to use and create new docker container
[root@ip-172-31-94-183 ~]# docker container run -it ubuntu /bin/bash
root@815b8c207540:/# cd tmp/
root@815b8c207540:/tmp# touch 1 2 3 4 56 7 8 90
root@815b8c207540:/tmp# ls
1 2 3 4 56 7 8 90
root@815b8c207540:/tmp# ls -lh
total 0
-rw-r--r-- 1 root root 0 Jul 11 08:47 1
-rw-r--r-- 1 root root 0 Jul 11 08:47 2
-rw-r--r-- 1 root root 0 Jul 11 08:47 3
-rw-r--r-- 1 root root 0 Jul 11 08:47 4
-rw-r--r-- 1 root root 0 Jul 11 08:47 56
-rw-r--r-- 1 root root 0 Jul 11 08:47 7
-rw-r--r-- 1 root root 0 Jul 11 08:47 8
-rw-r--r-- 1 root root 0 Jul 11 08:47 90
root@815b8c207540:/tmp# [root@ip-172-31-94-183 ~]#
[root@ip-172-31-94-183 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
815b8c207540 ubuntu "/bin/bash" 2 minutes ago Up About a minute dazzling_brown
e694e4e16ffd ubuntu "/bin/bash" 29 minutes ago Up 29 minutes friendly_meitner
[root@ip-172-31-94-183 ~]# docker container commit 815b8c207540 newimage
sha256:7b68b021455a6601029abda69f812f4a3fd45bb5800ea3c200ad295c13c8dda4
[root@ip-172-31-94-183 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
newimage latest 7b68b021455a 19 seconds ago 64.2MB
rajimage latest 9a7d5e7ed5a5 16 minutes ago 183MB
ubuntu latest 4c108a37151f 3 weeks ago 64.2MB
[root@ip-172-31-94-183 ~]#
[root@ip-172-31-94-183 ~]# docker container rm -f 815b8c207540
815b8c207540
[root@ip-172-31-94-183 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e694e4e16ffd ubuntu "/bin/bash" 36 minutes ago Up 36 minutes friendly_meitner
[root@ip-172-31-94-183 ~]# docker container run -it newimage /bin/bash
root@e872b02b6002:/# cd tmp/
root@e872b02b6002:/tmp# ls
1 2 3 4 56 7 8 90
root@e872b02b6002:/tmp#
[root@ip-172-31-94-183 ~]# docker container run -it ubuntu /bin/bash
root@815b8c207540:/# cd tmp/
root@815b8c207540:/tmp# touch 1 2 3 4 56 7 8 90
root@815b8c207540:/tmp# ls
1 2 3 4 56 7 8 90
root@815b8c207540:/tmp# ls -lh
total 0
-rw-r--r-- 1 root root 0 Jul 11 08:47 1
-rw-r--r-- 1 root root 0 Jul 11 08:47 2
-rw-r--r-- 1 root root 0 Jul 11 08:47 3
-rw-r--r-- 1 root root 0 Jul 11 08:47 4
-rw-r--r-- 1 root root 0 Jul 11 08:47 56
-rw-r--r-- 1 root root 0 Jul 11 08:47 7
-rw-r--r-- 1 root root 0 Jul 11 08:47 8
-rw-r--r-- 1 root root 0 Jul 11 08:47 90
root@815b8c207540:/tmp# [root@ip-172-31-94-183 ~]#
[root@ip-172-31-94-183 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
815b8c207540 ubuntu "/bin/bash" 2 minutes ago Up About a minute dazzling_brown
e694e4e16ffd ubuntu "/bin/bash" 29 minutes ago Up 29 minutes friendly_meitner
[root@ip-172-31-94-183 ~]# docker container commit 815b8c207540 newimage
sha256:7b68b021455a6601029abda69f812f4a3fd45bb5800ea3c200ad295c13c8dda4
[root@ip-172-31-94-183 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
newimage latest 7b68b021455a 19 seconds ago 64.2MB
rajimage latest 9a7d5e7ed5a5 16 minutes ago 183MB
ubuntu latest 4c108a37151f 3 weeks ago 64.2MB
[root@ip-172-31-94-183 ~]#
[root@ip-172-31-94-183 ~]# docker container rm -f 815b8c207540
815b8c207540
[root@ip-172-31-94-183 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e694e4e16ffd ubuntu "/bin/bash" 36 minutes ago Up 36 minutes friendly_meitner
[root@ip-172-31-94-183 ~]# docker container run -it newimage /bin/bash
root@e872b02b6002:/# cd tmp/
root@e872b02b6002:/tmp# ls
1 2 3 4 56 7 8 90
root@e872b02b6002:/tmp#
No comments:
Post a Comment