Task Requirements :
One of the company's developers 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.
- Create an image blog:xfusion on Application Server 1 from a container ubuntu_latest that is running on the same server.
Execution :
To create a new Docker image from a running container, you can follow these steps.
SSH into Application Server 1
ssh your_username@application_server_1_ip
Commit Changes to a New Image
docker commit ubuntu_latest blog:xfusion
This command creates a new image named blog:xfusion based on the changes made in the ubuntu_latest container.
Verify the New Image
docker images
(Optional) Save the Image to a File
If you need to transfer the image to another server, you can save it to a tarball and then copy it to the desired location
docker save -o blog_xfusion.tar blog:xfusion
You can then use scp
or any other file transfer method to move the blog_xfusion.tar
file to the target server.
(Optional) Load Image on Another Server
If you've saved the image to a tarball and transferred it to another server, you can load it on that server.
docker load -i blog_xfusion.tar
Now, you have a Docker image named blog:xfusion based on the changes made in the ubuntu_latest container on Application Server 1. You can use this image to spin up containers with the desired configuration.