We face 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 use them directly without too much configuration.
So let’s start with the approach.
To commit the running container to an image with the new tag you can use this command,
docker commit <containerID> new_image_name:tag
To save the replica of the image which we created using the above command use 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 from the location of 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 use,
docker images
The last step is run,
docker-compose up -d
I hope you understand all the things which I discussed in this blog.
If you want to look deeply into docker then please read my blog where I mention how docker works, how to create .Net API and Angular Application and its Dynamic Configurations
Thanks!