Based on ZhuangweiKang/Docker-CRIU-Live-Migration
Differences:
- I don't know whether it is live migration, so I delete the "live" in the name.
- Delete the kernel part, for I didn't encounter kernel issues.
- Delete the firewall part. If you need firewall, read the origin repo.
- Write shell install for it, including
host.sh
andclient.sh
. - Update the method to install docker and criu.
Disclaimer: I am not responsible for any damage. Making any modifications to your device is your own choice only! Recommend for reading the shell before executing it.
Prerequests:
- Two Ubuntu 16.04 servers.
- Install docker and criu.
- Some configurations for docker.
- Run without sudo.
- Enable experimental feature to use checkpoint.
- Install nfs to allow client to mount host. So client can get the checkpoint files from host and restore using these files.
- Test your migration.
-
Install docker
curl -fsSL get.docker.com | VERSION=17.03.0-ce sh
Notes:
- Install the old version of docker. Some of experimental functions are not included in new version.
- This shell may not work well on Ubuntu > 16.04.
- For more information about this shell to install docker, see this.
-
Install criu
sudo apt-get install criu
-
Configuration
Clone this repo both in your host and client.
-
On the host:
sudo host.sh
Attention:
- It will destroy your origin configurations about
/etc/exports
in your host.
- It will destroy your origin configurations about
-
On the client:
sudo client.sh
Notes:
- Use
df -h
in your client to see whether your host has mounted your client.
- Use
- Test your live migration
- On the host
docker run -d --name looper2 --security-opt seccomp:unconfined busybox \
/bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
# wait a few seconds to give the container an opportunity to print a few lines, then
docker checkpoint create --checkpoint-dir=/home/ubuntu/Container-Checkpoints/ looper2 checkpoint2
# check your container & print log file
docker ps
docker logs looper2
- On the client
docker create --name looper-clone --security-opt seccomp:unconfined busybox \
/bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'
docker start --checkpoint-dir=/nfs/home/ubuntu/Container-Checkpoints/ --checkpoint=checkpoint2 looper-clone
# check your container
docker ps
docker logs looper-clone