Aim of this project is to automate the process of creating a Docker image containing application checkpoint using CRIU.
You can use the scripts to start your application in a container, checkpoint it and commit the container to create a new docker image containing the application checkpoint.
To use these scripts for your application, you need to create a directory at the same level as the driver.sh
script and add some scripts specific to your application in that directory, as explained in next section.
For a new application create a directory, lets say mytest
at the same level as driver.sh
script. Inside the directory add following files:
run_mytest.sh: This script is used to start the application docker image. It is passed three parameters:
- application name, eg in this case it would be
mytest
- application docker image
- container name
run_app.sh: This script should contain the commands to start the application in the docker container.
app_env_vars.sh: It contains application specific environment variables. A template for this is present at the top level. Copy it to your test directory and update the env variables. Current env variables to be defined are:
DOCKER_IMAGE_OS
: OS image used by the application docker image. Valid values areubuntu
anddebian
.CONTAINER_USER
: User in the application docker imageLOG_MESSAGE
: Indicates the message generated by the application at which checkpoint needs to be takenLOG_LOCATION
: File whereLOG_MESSAGE
needs to be searched for. If the message is dumped on standard output, usedstdout
as the value.APP_DOCKER_IMAGE
: Original docker image of the applicatonAPP_CR_DOCKER_IMAGE
: Name of the docker image that would be created containing the application checkpoint
Once the above changes are done, you can go one level up and execute following command:
$ ./driver.sh mytest
At the end you will have a new docker image containing your application checkpoint.
This section assumes there exists a directory mytest
for your application and you have added the scripts mentioned in the Usage section.
The execution starts with driver.sh
that creates a temporary docker image based on the original application docker image. The temporary image has criu
installed in it along with other scripts for starting the application and restoring it from the checkpoint. driver.sh
then invokes mytest/run_mytest.sh
.
run_mytest.sh
starts the docker container using the temporary image. Inside the container, the entry point is set to run_app.sh
which starts the application.
The driver.sh
keeps looking at LOG_LOCATION
for LOG_MESSAGE
which indicates the application is ready to be checkpointed. At this point, it using criu dump
to create the checkpoint and commit the container to create new docker image containing the application checkpoint.
Look at acmeair and jenkins directory as examples of the applications using this mechanism.