How to move Docker containers between different hosts?

Dinesh Reddy picture Dinesh Reddy · Feb 26, 2015 · Viewed 119.6k times · Source

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.

Answer

aholt picture aholt · Feb 26, 2015

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