dockercontainersdocker-registry

How to move Docker containers between different hosts?


I cannot find a way of moving docker running containers from one host to another.

Is there any way I can push my containers to repositories like we do for images ? Currently, I am not using data volumes to store the data associated with applications running inside containers. So some data resides inside containers, which I want to persist before redesigning the setup.


Solution

  • You cannot move a running docker container from one host to another.

    You can commit the changes in your container to an image with docker commit, move the image onto a new host, and then start a new container with docker run. This will preserve any data that your application has created inside the container.

    NB: It does not preserve data that is stored inside volumes; you need to move data volumes manually to new host.