<div dir="ltr">Great!  Here is some additional text for the HOWTO page that introduces docker_cr.sh and explains its usage.<div><br></div><div>--Saied</div><div><br></div><div><br></div><div><div>Helper Script</div><div><br></div><div>As seen in the above examples, the CRIU command line for checkpointing and</div><div>restoring a Docker container is pretty long.  For restore, there is also</div><div>an additional step to set up the root filesystem before invoking CRIU.</div><div><br></div><div>To automate the C/R process, there is a helper script in the contrib</div><div>subdirectory of CRIU sources, called docker_cr.sh.  In addition to</div><div>invoking CRIU, this helper script sets up the root filesystem for AUFS,</div><div>UnionFS, and VFS for restore.</div><div><br></div><div>With docker_cr.sh, all you have to provide is the container ID.</div><div>If you don&#39;t specify a container ID, docker_cr.sh will list all running</div><div>containers and prompt you to choose one.  Also, as shown in the help</div><div>output below, by setting the appropriate environment variable, it&#39;s</div><div>possible to tell docker_cr.sh which Docker and CRIU binaries to use,</div><div>where Docker&#39;s home directory is, and where CRIU should save and look</div><div>for its image files.</div><div><br></div><div># docker_cr.sh --help</div><div>Usage:</div><div><span class="" style="white-space:pre">        </span>docker_cr.sh -c|-r [-hv] [&lt;container_id&gt;]</div><div><span class="" style="white-space:pre">        </span>-c, --checkpoint<span class="" style="white-space:pre">        </span>checkpoint container</div><div><span class="" style="white-space:pre">        </span>-h, --help<span class="" style="white-space:pre">                </span>print help message</div><div><span class="" style="white-space:pre">        </span>-r, --restore<span class="" style="white-space:pre">                </span>restore container</div><div><span class="" style="white-space:pre">        </span>-v, --verbose<span class="" style="white-space:pre">                </span>enable verbose mode</div><div><br></div><div>Environment:</div><div><span class="" style="white-space:pre">        </span>DOCKER_HOME<span class="" style="white-space:pre">                </span>(default /var/lib/docker)</div><div><span class="" style="white-space:pre">        </span>CRIU_IMG_DIR<span class="" style="white-space:pre">                </span>(default /var/lib/docker/criu_img)</div><div><span class="" style="white-space:pre">        </span>DOCKER_BINARY<span class="" style="white-space:pre">                </span>(default docker)</div><div><span class="" style="white-space:pre">        </span>CRIU_BINARY<span class="" style="white-space:pre">                </span>(default criu)</div><div><br></div><div>Below is an example to checkpoint and restore Docker container 4397:</div><div><br></div><div># docker_cr.sh -c 4397</div><div>dump successful</div><div># docker_cr.sh -r 4397</div><div>restore successful</div><div><br></div><div>Optionally, you can specify -v to see the commands that docker_cr.sh</div><div>executes.  For example:</div><div><br></div><div># docker_cr.sh -c -v 40d3</div><div>docker binary: docker</div><div>criu binary: criu</div><div>image directory: /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div>container root directory: /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div><br></div><div>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</div><div><br></div><div>dump successful</div><div>(00.020827) Dumping finished successfully</div><div><br></div><div># docker_cr.sh -r -v 40d3</div><div>docker binary: docker</div><div>criu binary: criu</div><div>image directory: /var/lib/docker/criu_img/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div>container root directory: /var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div><br></div><div>mount -t aufs -o</div><div>/var/lib/docker/aufs/diff/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div>/var/lib/docker/aufs/diff/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf-init</div><div>/var/lib/docker/aufs/diff/a9eb172552348a9a49180694790b33a1097f546456d041b6e82e4d7716ddb721</div><div>/var/lib/docker/aufs/diff/120e218dd395ec314e7b6249f39d2853911b3d6def6ea164ae05722649f34b16</div><div>/var/lib/docker/aufs/diff/42eed7f1bf2ac3f1610c5e616d2ab1ee9c7290234240388d6297bc0f32c34229</div><div>/var/lib/docker/aufs/diff/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158</div><div>none</div><div>/var/lib/docker/aufs/mnt/40d363f564e00a2f893579fa012a200e475dcf8df47f2a22b7dd0860ffc3d7bf</div><div><br></div><div>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</div><div><br></div><div>restore successful</div><div>(00.408807) Restore finished successfully. Resuming tasks.</div><div><br></div><div>root      6206     1  1 10:49 ?        00:00:00 /bin/sh -c i=0; while true; do echo $i &gt;&gt; /foo; i=$(expr $i + 1); sleep 3; done</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 9, 2014 at 5:10 AM, Pavel Emelyanov <span dir="ltr">&lt;<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 09/03/2014 11:28 PM, Filipe Brandenburger wrote:<br>
</span><span class="">&gt; Acked-by: Filipe Brandenburger &lt;<a href="mailto:filbranden@google.com">filbranden@google.com</a>&gt;<br>
&gt;<br>
&gt; On Wed, Sep 3, 2014 at 12:27 PM, Saied Kazemi &lt;<a href="mailto:saied@google.com">saied@google.com</a>&gt; wrote:<br>
&gt;&gt; As promised, here is a shell script to simplify checkpointing and restoring<br>
&gt;&gt; a Docker container.  The usage is pretty simple and obvious.  Try<br>
&gt;&gt; docker_cr.sh --help to get started.  I suggest adding this file to the<br>
&gt;&gt; scripts subdirectory of CRIU and installing it where criu is installed, but<br>
&gt;&gt; I have not modified the Makefile.<br>
&gt;&gt;<br>
&gt;&gt; I&#39;d like to acknowledge Filipe&#39;s time for his review and feedback.<br>
&gt;&gt;<br>
&gt;&gt; Cheers!<br>
<br>
</span>Sorry for the delay. The patch is applied with the scripts/ -&gt; contrib/<br>
directory change. Huge thanks!<br>
<br>
</blockquote></div><br></div>