DEV Community

Jaydeep Patil
Jaydeep Patil

Posted on • Updated on

Docker Image Import and Export to another Machine

Image description

We faced daily challenges while working with docker many times we want to save our running images and want to import/export them to another machine and load them on that machine and used them directly without too much configuration.

So Let’s start,

To commit the running container to an image with the new tag you can use this command :

docker commit <containerID> new_image_name:tag

If you want to know the running container id then use the following command

docker ps

To save the replica of the image which we created using the above command using the following command

docker save -o new_file_name.tar new_image_name:tag

After executing the above command you can see the .tar file of your image on your machine from the location where you executed the above command

Now you can move your docker-compose.yml to the same folder on another machine and your new_file_name.tar too. On your machine where are these files run :

docker load --input new_file_name.tar

Change all docker-compose.yml files as per image we load with name and its tag

If you lost the name used:

docker images

The last step is run :

docker-compose up -d

I hope you understand all the things which I discussed in this article.

Happy Learning!

Top comments (0)