Export Command:-
[root@ip-172-31-94-183 ~]# docker container run -it ubuntu /bin/bash
root@e694e4e16ffd:/# apt-get update
root@e694e4e16ffd:/# apt-get install tree git -y
[root@ip-172-31-94-183 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e694e4e16ffd ubuntu "/bin/bash" 5 minutes ago Up 5 minutes friendly_meitner
[root@ip-172-31-94-183 ~]# docker container export e694e4e16ffd >raj.tar
[root@ip-172-31-94-183 ~]# ls -lh
total 180M
-rw-r--r-- 1 root root 180M Jul 11 08:25 raj.tar
[root@ip-172-31-94-183 ~]#
or
[root@ip-172-31-94-183 ~]# docker container export e694e4e16ffd -o raj1.tar
[root@ip-172-31-94-183 ~]# ls -lh
total 359M
-rw------- 1 root root 180M Jul 11 08:27 raj1.tar
-rw-r--r-- 1 root root 180M Jul 11 08:25 raj.tar
[root@ip-172-31-94-183 ~]#
Now share this tar file with other which you want
Import Command:-
Now other need to convert above tar file into image to use and create container
[root@ip-172-31-94-183 ~]# docker image import raj.tar rajimage
sha256:9a7d5e7ed5a54191780d734004d6a8fe8ab35c5bf6c108e7a20a125afb95330c
[root@ip-172-31-94-183 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
rajimage latest 9a7d5e7ed5a5 23 seconds ago 183MB
ubuntu latest 4c108a37151f 3 weeks ago 64.2MB
[root@ip-172-31-94-183 ~]# docker container run -it rajimage /bin/bash
root@4f609111b319:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@4f609111b319:/# cd tmp/
root@4f609111b319:/tmp# tree
.
0 directories, 0 files
root@4f609111b319:/tmp# git --version
git version 2.17.1
root@4f609111b319:/tmp#
No comments:
Post a Comment