CRaC 6 demo
Running the demo in a docker container (on a Linux x64 machine)
1. Create docker image
- Open a shell window
- Change to the crac6 folder
- Run
docker build -t crac6 .
to build the docker image
2. Start the application in a docker container
- Open a shell window
- Run
docker run -it --privileged --rm --name crac6 crac6
- In the docker container run
cd /opt/app java -XX:CRaCCheckpointTo=/opt/crac-files -jar crac6-17.0.0.jar
- Note the PID of the program
3. Start a 2nd shell window and create the checkpoint
- Open a second shell window
- Run
docker exec -it -u root crac6 /bin/bash
- Wait until the program in the first window reaches for example the 17th iteration
- Take the PID from shell 1 and run
jcmd PID JDK.checkpoint
- In the first shell window the application should have created the checkpoint
- In second shell window run
exit
to get back to your machine
4. Commit the current state of the docker container
- Now get the CONTAINER_ID from shell window 1 by execute
docker ps -a
in shell window 2 - Run
docker commit CONTAINER_ID crac6:checkpoint
in shell window 2 - Go back to shell window 1 and execute
exit
to stop the container
5. Run the docker container from the saved state incl. the checkpoint
Now you can start the docker container from the checkpoint by executing
docker run -it --privileged --rm --name crac6 crac6:checkpoint java -XX:CRaCRestoreFrom=/opt/crac-files
6. Create a shell script to restore multiple times
- Open a shell window
- Create a text file named
restore_docker.sh
- Add
#!/bin/bash
echo "docker run -it --privileged --rm --name $1 crac6:checkpoint java -XX:CRaCRestoreFrom=/opt/crac-files"
docker run -it --privileged --rm --name $1 crac6:checkpoint java -XX:CRaCRestoreFrom=/opt/crac-files
- Make the script executable by executing
chmod +x restore_docker.sh
- Now you can start the docker container multiple times executing
restore_docker.sh NAME_OF_CONTAINER
If you would like to start the original container without the checkpoint you can still do that by executing the following command
docker run -it --privileged --rm --name crac6 crac6 java -jar /opt/app/crac6-17.0.0.jar