0

I am a beginner with docker and have created a docker-compose.yml file. Everything is running well, but I want to move my container that is generated by "docker-compose up" to another machine. How can I save/export my container that is running my services of the docker-compose.yml to another machine?

Thanks

Dovosi22
  • 29
  • 4
  • Take a look at these 2 questions: [How to copy Docker images from one host to another without using a repository](https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository), [How to move Docker containers between different hosts?](https://stackoverflow.com/questions/28734086/how-to-move-docker-containers-between-different-hosts) because it seems that you need something similar – tgogos Apr 26 '21 at 10:08
  • @tgogos ok, so my docker-compose creates an image for each service inside the yml file and thus I need to save every image created? Docker-compose build doesn't generate a single image that I can save? – Dovosi22 Apr 26 '21 at 10:11

1 Answers1

3

For commit running container to image with new tag you can use this command :

$ docker commit <containerID> new_image_name:tag

For save new_image_name:tag to file use :

$ docker save -o new_file_name.tar new_image_name:tag

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

$ docker load --input new_file_name.tar

Rewrite in docker-compose.yml section image: to your new_image_name:tag

If you lost the name use :

$ docker images

and continue with $ docker load..... from above

Last step is run :

$ docker-compose up -d