How to migrate your Docker containers to another host

By   01-18-2015 · 2 minute read · 226 words


I was running Docker happily on Ubuntu one day and got an email from Digital Ocean notifying me that my droplet was involved in a DDOS with some foreign nations servers.

Not happy about this and not wanting to spend an hour troubleshooting, I decided to vacate the droplet and move to a proper build of Coreos rather than risk getting banned by DO. Why else use Docker right? You can abandon the host and just move your container and be back in business in no time.

The issue was how to move your containers out of my Ubuntu host and onto my new install of CoreOS? If you had a registry server you could just push to that, but I didn’t have one and the public registry was out of the question.

Luckily it was really simple to get the container backed up and moved.

First, commit your actively running container into a image.

docker commit mysql dkyio/mysqlcontainer

Next we can export the image into a tar file for scp/ftp transfer to the new host.

docker save dkyio/mysqlcontainer > mysqlcontainer.tar

Once it’s on the Docker host you can load it into Docker.

docker load --input=mysqlcontainer.tar

From there validate that the image loaded successfully and attempt to run it.

$docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
dkyio/mysqlcontainer   latest              df85b93403f9        5 weeks ago         541.4 MB

docker  

comments powered by Disqus