Question: One of the Nautilus developer was working to test new changes on a container. He wants to keep a backup of his changes to the container. A new request has been raised for the DevOps team to create a new image from this container. Below are more details about it:
a. Create an image media:datacenter on Application Server 2 from a container ubuntu_latest that is running on same server.
Solution:
1. Login on app server ( Refer your task) & Switch to root user
|
thor@jump_host
~$ ssh steve@stapp02 The authenticity
of host 'stapp02 (172.16.238.11)' can't be established. ECDSA key
fingerprint is SHA256:VqDmFflIgUQEQ0mKslpNubcER8NdSK9rnbP0q4HFnos. ECDSA key
fingerprint is MD5:ef:78:a5:4c:c0:cc:90:3e:dd:ea:f3:72:19:61:28:d9. Are you sure you
want to continue connecting (yes/no)? yes Warning:
Permanently added 'stapp02,172.16.238.11' (ECDSA) to the list of known hosts. steve@stapp02's
password: [steve@stapp02
~]$ sudo su - We trust you
have received the usual lecture from the local System Administrator.
It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great
responsibility. [sudo] password
for steve: [root@stapp02
~]# |
2. Check existing docker container ubuntu_latest running status
|
[root@stapp02
~]# docker ps CONTAINER
ID IMAGE COMMAND
CREATED STATUS PORTS NAMES e44ada0bb828 ubuntu
"bash" 2 minutes
ago Up 2 minutes ubuntu_latest [root@stapp02
~]# |
3. Look at the list of images on your system
|
[root@stapp02
~]# docker images REPOSITORY TAG
IMAGE ID CREATED SIZE ubuntu latest 1318b700e415 12 days ago 72.8MB [root@stapp02
~]# |
4. Create a new image from this container as per the task
|
[root@stapp02
~]# docker commit ubuntu_latest media:datacenter sha256:262c15389ffd0c8be00efa9b4364e678f6d5c337dd0658382d85cea77bd72a37 [root@stapp02
~]# |
5. Validate the task by running
|
[root@stapp02
~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE media datacenter 262c15389ffd 13 seconds ago 103MB ubuntu latest 1318b700e415 12 days ago 72.8MB [root@stapp02
~]# |
6. Click on Finish & Confirm to complete the task successfully
Happy Learning!!!!
2 Comments
Hi,
ReplyDeleteI'm curious, why is the new image (demo:datacenter) bigger than original (ubuntu_latest)?
[root@stapp03 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
demo datacenter 5b54d28983a3 5 seconds ago 103MB
ubuntu latest 1318b700e415 11 days ago 72.8MB
Hi Dannie,
DeleteThe more layers an image have the larger the result size is.
The increased size can have multiple reasons .
You can easily check the difference and probably the reason for the inflated image size with the docker diff {container_name}, which shows you exactly the differences.