[CRIU] Docker HOWTO
Pavel Emelyanov
xemul at parallels.com
Fri Sep 12 00:59:50 PDT 2014
On 09/11/2014 10:11 PM, Saied Kazemi wrote:
> Great! Here is some additional text for the HOWTO page that introduces
> docker_cr.sh and explains its usage.
It's very useful, thanks :) Can you integrate this text into
the http://criu.org/Docker page?
> --Saied
>
>
> Helper Script
>
> As seen in the above examples, the CRIU command line for checkpointing and
> restoring a Docker container is pretty long. For restore, there is also
> an additional step to set up the root filesystem before invoking CRIU.
>
> To automate the C/R process, there is a helper script in the contrib
> subdirectory of CRIU sources, called docker_cr.sh. In addition to
> invoking CRIU, this helper script sets up the root filesystem for AUFS,
> UnionFS, and VFS for restore.
>
> With docker_cr.sh, all you have to provide is the container ID.
> If you don't specify a container ID, docker_cr.sh will list all running
> containers and prompt you to choose one. Also, as shown in the help
> output below, by setting the appropriate environment variable, it's
> possible to tell docker_cr.sh which Docker and CRIU binaries to use,
> where Docker's home directory is, and where CRIU should save and look
> for its image files.
>
> # docker_cr.sh --help
> Usage:
> docker_cr.sh -c|-r [-hv] [<container_id>]
> -c, --checkpointcheckpoint container
> -h, --helpprint help message
> -r, --restorerestore container
> -v, --verboseenable verbose mode
>
> Environment:
> DOCKER_HOME(default /var/lib/docker)
> CRIU_IMG_DIR(default /var/lib/docker/criu_img)
> DOCKER_BINARY(default docker)
> CRIU_BINARY(default criu)
>
> Below is an example to checkpoint and restore Docker container 4397:
>
> # docker_cr.sh -c 4397
> dump successful
> # docker_cr.sh -r 4397
> restore successful
>
> Optionally, you can specify -v to see the commands that docker_cr.sh
> executes. For example:
>
> # docker_cr.sh -c -v 40d3
> docker binary: docker
> criu binary: criu
> image directory: /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
> container root directory: /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
>
> criu dump -v4 -D /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf -o dump.log --manage-cgroups --evasive-devices --ext-mount-map /etc/resolv.conf:/etc/resolv.conf --ext-mount-map /etc/hosts:/etc/hosts --ext-mount-map /etc/hostname:/etc/hostname --ext-mount-map /.dockerinit:/.dockerinit -t 5991 --root /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
>
> dump successful
> (00.020827) Dumping finished successfully
>
> # docker_cr.sh -r -v 40d3
> docker binary: docker
> criu binary: criu
> image directory: /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
> container root directory: /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
>
> mount -t aufs -o
> /var/lib/docker/aufs/diff/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
> /var/lib/docker/aufs/diff/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf-init
> /var/lib/docker/aufs/diff/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721
> /var/lib/docker/aufs/diff/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16
> /var/lib/docker/aufs/diff/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229
> /var/lib/docker/aufs/diff/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158
> none
> /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf
>
> criu restore -v4 -D /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf -o restore.log --manage-cgroups --evasive-devices --ext-mount-map /etc/resolv.conf:/var/lib/docker/containers/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf/resolv.conf --ext-mount-map /etc/hosts:/var/lib/docker/containers/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf/hosts --ext-mount-map /etc/hostname:/var/lib/docker/containers/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf/hostname --ext-mount-map /.dockerinit:/var/lib/docker/init/dockerinit-1.0.0 -d --root /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf --pidfile /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf/restore.pid
>
> restore successful
> (00.408807) Restore finished successfully. Resuming tasks.
>
> root 6206 1 1 10:49 ? 00:00:00 /bin/sh -c i=0; while true; do echo $i >> /foo; i=$(expr $i + 1); sleep 3; done
>
>
>
> On Tue, Sep 9, 2014 at 5:10 AM, Pavel Emelyanov <xemul at parallels.com <mailto:xemul at parallels.com>> wrote:
>
> On 09/03/2014 11:28 PM, Filipe Brandenburger wrote:
> > Acked-by: Filipe Brandenburger <filbranden at google.com <mailto:filbranden at google.com>>
> >
> > On Wed, Sep 3, 2014 at 12:27 PM, Saied Kazemi <saied at google.com <mailto:saied at google.com>> wrote:
> >> As promised, here is a shell script to simplify checkpointing and restoring
> >> a Docker container. The usage is pretty simple and obvious. Try
> >> docker_cr.sh --help to get started. I suggest adding this file to the
> >> scripts subdirectory of CRIU and installing it where criu is installed, but
> >> I have not modified the Makefile.
> >>
> >> I'd like to acknowledge Filipe's time for his review and feedback.
> >>
> >> Cheers!
>
> Sorry for the delay. The patch is applied with the scripts/ -> contrib/
> directory change. Huge thanks!
>
>
>
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
More information about the CRIU
mailing list