Skip to main content

Command Palette

Search for a command to run...

Create Docker Image From Container

Published
•2 min read•View as Markdown
Create Docker Image From Container
S

DevOps enthusiast sharing real-world insights. 🚀 #Automation #CI/CD #InfrastructureAsCode

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.

More from this blog

DevOps Task Diaries

19 posts

Welcome to my DevOps documentation blog! I'm Samson Oladipo, and I'm passionate about sharing real-world DevOps scenarios, experiences, and best practices with the global tech community.

Join me on this DevOps journey as we explore the fascinating world of IT operations and software development, one task at a time. Whether you're a seasoned pro or just beginning your DevOps adventure, you'll find valuable insights and practical guidance to help you succeed in your own DevOps endeavors.