Search code examples
linuxdockerlinux-containers

Backup a running Docker container?


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


Solution

  • 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!