How To Save And Load Docker Container On Rocky Linux 8.6
- 00:31 cat /etc/os-release
- 00:47 docker run -it ubuntu:latest /bin/bash
- 01:19 mkdir test
- 01:28 exit
- 01:36 docker ps -a
- 01:44 docker start e6a00b69c3b4
- 02:07 docker commit awesome_robinson ubuntu:test
- 02:31 docker stop awesome_robinson
- 03:01 docker save ubuntu:test > ubuntu.test.tar
- 03:25 ls -la
- 03:37 docker images
- 03:58 docker rmi bad79cc8ac0b
- 04:25 docker load < ubuntu.test.tar
- 05:07 docker run -it ubuntu:test /bin/bash
- 05:37 ls -la
To save and load Docker container on Rocky Linux 8.6
Introduction
The Docker container allows us to separate applications from infrastructure, which makes it easier to develop, ship, and run software quickly. In addition, we can manage our infrastructure the same way we manage our applications.
Installation Procedure
Step 1: Check the OS version by using following commands
[root@linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
Step 2: Run the Docker image with Bash Shell by using the below command
[root@linuxhelp ~]# docker run -it ubuntu:latest /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
405f018f9d1d: Pull complete
Digest: sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac
Status: Downloaded newer image for ubuntu:latest
Step 3: Create a directory by using the below command
root@e6a00b69c3b4:/# mkdir test
Step 4: Exit from the image by using the below command
root@e6a00b69c3b4:/# exit
exit
Step 5: List the container by using the Docker command
[root@linuxhelp ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e6a00b69c3b4 ubuntu:latest "/bin/bash" 58 seconds ago Exited (0) 18 seconds ago awesome_robinson
Step 6: Start the Container by using the below command
[root@linuxhelp ~]# docker start e6a00b69c3b4
e6a00b69c3b4
Step 7: Commit the Docker container by using the below command
[root@linuxhelp ~]# docker commit awesome_robinson ubuntu:test
sha256:bad79cc8ac0bde6107074c12ec03d5810cc9ff33bacd4ed17cc89b6480d3840d
Step 8: Stop the container by using the below command
[root@linuxhelp ~]# docker stop awesome_robinson
awesome_robinson
Step 9: Save the Docker container as tar file by using the below command
[root@linuxhelp ~]# docker save ubuntu:test > ubuntu.test.tar
Step 10: List the saved file by using the below command
[root@linuxhelp ~]# ls -la
-rw-r--r--. 1 root root 80356864 Jul 26 17:12 ubuntu.test.tar
Step 11: List the Docker images by using the below command
[root@linuxhelp ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu test bad79cc8ac0b About a minute ago 77.8MB
ubuntu latest 27941809078c 7 weeks ago 77.8MB
Step 12: Remove the images by using container ID by using the below command
[root@linuxhelp ~]# docker rmi bad79cc8ac0b
Untagged: ubuntu:test
Deleted: sha256:bad79cc8ac0bde6107074c12ec03d5810cc9ff33bacd4ed17cc89b6480d3840d
Deleted: sha256:3f0e5ea4b306ed14ec7eb62a4ba02f67fab33342abc43f32b55e359b7c30c12b
Step 13: Load the saved container by using the below command
[root@linuxhelp ~]# docker load < ubuntu.test.tar
937aaa21edb2: Loading layer 3.584kB/3.584kB
Loaded image: ubuntu:test
Step 14: Run the loaded Docker image with Bash Shell by using the below command
[root@linuxhelp ~]# docker run -it ubuntu:test /bin/bash
Step 15: List the created file by using the below command
root@1f3395c1e71a:/# ls -la
total 0
drwxr-xr-x. 1 root root 6 Jul 26 21:15 .
drwxr-xr-x. 1 root root 6 Jul 26 21:15 ..
-rwxr-xr-x. 1 root root 0 Jul 26 21:15 .dockerenv
lrwxrwxrwx. 1 root root 7 May 31 15:42 bin -> usr/bin
drwxr-xr-x. 2 root root 6 Apr 18 10:28 boot
drwxr-xr-x. 5 root root 360 Jul 26 21:15 dev
drwxr-xr-x. 1 root root 66 Jul 26 21:15 etc
drwxr-xr-x. 2 root root 6 Apr 18 10:28 home
lrwxrwxrwx. 1 root root 7 May 31 15:42 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 May 31 15:42 lib32 -> usr/lib32
lrwxrwxrwx. 1 root root 9 May 31 15:42 lib64 -> usr/lib64
lrwxrwxrwx. 1 root root 10 May 31 15:42 libx32 -> usr/libx32
drwxr-xr-x. 2 root root 6 May 31 15:42 media
drwxr-xr-x. 2 root root 6 May 31 15:42 mnt
drwxr-xr-x. 2 root root 6 May 31 15:42 opt
dr-xr-xr-x. 264 root root 0 Jul 26 21:15 proc
drwx------. 1 root root 27 Jul 26 21:10 root
drwxr-xr-x. 5 root root 46 May 31 15:45 run
lrwxrwxrwx. 1 root root 8 May 31 15:42 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 May 31 15:42 srv
dr-xr-xr-x. 13 root root 0 Jun 24 02:31 sys
drwxr-xr-x. 2 root root 6 Jul 26 21:10 test
drwxrwxrwt. 2 root root 6 May 31 15:45 tmp
drwxr-xr-x. 14 root root 160 May 31 15:42 usr
drwxr-xr-x. 11 root root 139 May 31 15:45 var
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to save and load Docker container on Rocky Linux 8.6. Your feedback is much welcome.
Comments ( 0 )
No comments available