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 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.

  • Cannot start Sonatype Nexus3 service when running docker Windows image
  • How to start selenium hub and one linked node via docker-compose instead of using docker?
  • how to set the service mode when using docker compose?
  • docker run -> name is already in use by container
  • Starting Xserver in Docker Ubuntu container
  • Dynamically routing hosts to dockers
  • Any help is appreciated.

  • Rails scaffolding with docker and file ownership
  • How do you perform Django database migrations when using Docker-Compose?
  • docker daemon error running devicecreate createpool
  • Strange Vagrant error with Docker and shell provisioners
  • How to figure out if docker master or agent running
  • how to configure sensu keepalive to throw an alert to slack
  • 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 export does 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 export will export the contents
    of the underlying directory, not the contents of the volume. Refer
    to Backup, restore, or migrate data
    volumes
    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/

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.