[CRIU] Docker HOWTO

Saied Kazemi saied at google.com
Fri Sep 5 08:00:59 PDT 2014


Hi Pavel,

Thank you :)  You're right, this script will eventually go away but for now
it makes life much much easier, reducing the command line arguments to at
most one: the container ID.  So one would simply do:

$ sudo docker_cr.sh -c
$ sudo docker_cr.sh -r

If the container ID is not specified on the command line, the script shows
all containers and prompts the user to select the right one.  When entering
the ID, only enough characters to uniquely identify the container is
needed.  The -v flag can be optionally specified to enable verbose mode.

Without this script, one would have to invoke criu as follows to checkpoint:

$ sudo criu dump -o dump.log -v4 -t 17810 \
-D /tmp/img/<container_id> \
--root /var/lib/docker/aufs/mnt/<container_id> \
--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 \
--manage-cgroups \
--evasive-devices

And to restore, one would have to set up the filesystem first and then
invoke criu as follows:

$ sudo mount -t aufs -o br=\
/var/lib/docker/aufs/diff/<container_id>:\
/var/lib/docker/aufs/diff/<container_id>-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/<container_id>

$ sudo criu restore -o restore.log -v4 -d
-D /tmp/img/<container_id> \
--root /var/lib/docker/aufs/mnt/<container_id> \
--ext-mount-map
/etc/resolv.conf:/var/lib/docker/containers/<container_id>/resolv.conf \
--ext-mount-map /etc/hosts:/var/lib/docker/containers/<container_id>/hosts \
--ext-mount-map
/etc/hostname:/var/lib/docker/containers/<container_id>/hostname \
--ext-mount-map /.dockerinit:/var/lib/docker/init/dockerinit-1.0.0 \
--manage-cgroups \
--evasive-devices

So I suggest that this script be installed along with criu.

If you agree, I can prepare additional material for the Docker HOWTO page
to cover docker_cr.sh as well as AUFS and UnionFS support.

Cheers!

--Saied




On Fri, Sep 5, 2014 at 7:40 AM, Filipe Brandenburger <filbranden at google.com>
wrote:

> Hi Pavel,
>
> On Fri, Sep 5, 2014 at 7:34 AM, Pavel Emelyanov <xemul at parallels.com>
> wrote:
> > Guys, it's really great work you did with Docker! Do you think that this
> > script is better to be planted into criu sources? I thought that, since
> > we restore container detached from dockerd, some work will be done on the
> > Docker side, that that _it_ does all these preparations.
>
> Yes, the intention is to integrate criu support into libcontainer next
> (which should maybe solve the "detached after restore" issue) and then
> finally add hooks to docker (so that you can use "docker dump" and
> "docker restore"). At that point, we can probably obsolete this
> script.
>
> But while we worked on that, we can share this script that we have
> been using to test it internally, so that we can make it easier for
> others to try it as well :-)
>
> If you think scripts/ is not the best location for this script, maybe
> contrib/ would be good?
>
> Cheers,
> Filipe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140905/91cb7f07/attachment.html>


More information about the CRIU mailing list