Backup a running Docker container?

Slava V picture Slava V · Mar 29, 2013 · Viewed 22.1k times · Source

Is it possible to backup a running Docker container? Is the export command suitable for doing that?

Answer

JuliandotNut picture JuliandotNut · Jan 24, 2014

Posted by one friend in comments

Hi Slava, sorry that your question was closed. For the record, Slava is talking about docker.io, a runtime for linux containers. Yes, docker export is a suitable approach. It will generate a tarball of your entire container filesystem state, and dump it on stdout. So

docker export $CONTAINER_ID > $CONTAINER_ID-backup.tar

will yield a usable tarball. You can re-import the tarball with

docker import - slava/$CONTAINER_ID-backup < $CONTAINER_ID-backup.tar

Note the original metadata (eg id of the original image) will be lost. This should be fixed in future versions of docker. – Solomon Hykes Apr 2 '13 at 6:35

Adding here so one can find from summary that question was answered. Thanks Solomon!