How to move docker containers between different hosts
Is there any way I can push my containers to repos like we do it 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.
Any help is appreciated.
3 Solutions collect form web for “How to move docker containers between different hosts”
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.
alternatively, if you do not wish to push to a repository:
1) Export the container to a tarball
docker export <CONTAINER ID> > /home/export.tar
2) Move your tarball to new machine
3) Import it back
cat /home/export.tar | docker import - some-name:latest
From Docker documentation:
docker exportdoes not export the contents of volumes associated
with the container. If a volume is mounted on top of an existing
directory in the container,
docker exportwill export the contents
of the underlying directory, not the contents of the volume. Refer
to Backup, restore, or migrate data
in the user guide for examples on exporting data in a volume.
Other external tools:
In order to move a container with its associated data volume you can use Flocker https://clusterhq.com/flocker/introduction/