- Open a shell window
- Change to the crac6 folder
- Run
docker build -t crac6 .
to build the docker image
- 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
- 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
- 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
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
- 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