Skip to content

Hello World Docker

Antonio Barbalace edited this page Jun 14, 2020 · 6 revisions

Example for popcorn-hello migration from ARM to x86

Pull the Popcorn helloworld image from Docker hub

docker pull 123toorc/hcontainer-helloworld:hcontainer

Run docker image, the Docker Container ID will return on standard output, ARM need add capabilities

docker run --cap-add all -d 083c6d4dfcb3  

->	a40a7eb069172dc64dc771128cce91e942656f1cfe8b4d11ac97a99b08f64fd9

Notify the process, docker-popcorn-notify takes 2 arguments, the Container ID(long or short), target archtecture.

cd hcontainer-tutorial
./docker-popcorn-notify a40a7eb069172d x86-64

After notify succeeded, use docker checkpoint create to create a checkpoint, name is last arg (we name it as simple in this example)

docker checkpoint create a40a7eb069172d simple

Call recode script to recode the image file, it will copy the image file to current directory. recode.sh take 3 args, 1.Container Id (long or short) 2.Checkpoint name 3.Target archtecture

cd scripts/
./recode.sh a40a7eb069172d simple x86-64

recode.sh will take take the checkpoint, and the output directory will be generated in /tmp Send recode checkpoint images to target machine

scp -r /tmp/simple $target@x86_machine:~

Login to target machine

ssh $target@x86_machine

In target machine still need a same container, run the image just pulled, and stop the container before the restore.

docker pull 123toorc/hcontainer-helloworld:hcontainer

docker run --cap-add all 0beb2a3a9474

 ->	7637bbed740829f374c7ff365b171f387206acccb1b604af3b87ab537bbc44d2

docker container stop 7637bbed740829f374c7ff365b171f387206acccb1b604af3b87ab537bbc44d2

Copy the checkpoint images to target machine container checkpoints directory

cp -r ~/simple /var/lib/docker/containers/7637bbed740829f374c7ff365b171f387206acccb1b604af3b87ab537bbc44d2/checkpoints

Container restart from checkpoint

docker container start --checkpoint simple 7637bbed74082

If it shows running, which means migration successfully, also you can check popcorn-hello output in log file located in the container directory

docker ps

Example of using scripts

We provide scripts that can help you to do migration easily. Nginx is not support by script The scripts intros:

  1. check.sh will help user check current Cgroup support
  2. builder.sh is helper to build H-container
  3. dump.sh can help you dump the container and recode image, generate the dumped images in current dir, with Container ID and executable file given
  4. recode.sh is for process dumped images and recode it this is needed also for manually Docker migrate
  5. restore.sh is for restore Hcontainer in remote machine

popcorn.sh will call these scripts separately.
popcorn.sh takes 2 <required arguments> and [2 optional arguments]
<container directory> <target machine> [-p] [port:port]
There is more detail if you do ./popcorn.sh -h
This is a simple try of helloworld and redis:

./popcorn.sh ./helloworld [email protected] 
./popcorn.sh ./popcorn-redis [email protected] -p 6379:6379 

Clone this wiki locally