-
Notifications
You must be signed in to change notification settings - Fork 0
Nginx Server Docker
Tong XING edited this page Jun 11, 2020
·
7 revisions
The materials in H-Container Tutorial are needed.
In Dockerfile, the CMD ["./popcorn-nginx","-g","daemon off;"].
Because in Container, nginx is process 1, docker will exit when nginx initilazation is over
In order to keep container running, it needs args '-g daemon off;' to force it hang on.
cp -r nginx /usr/local
cd nginx_bin
cp popcorn-nginx_x86-64 popcorn-nginx
cp -r ../nginx_bin /app
docker build -t mynginx_x86 .
docker run --cap-add all -d -v /usr/local/nginx/logs/:/usr/local/nginx/logs/ -v /usr/local/nginx/conf/:/usr/local/nginx/conf/ mynginx_x86
4e6f433906d85a874acdc1b3138ffc9389e74e7120e11f5e0aa25dd08d3270f4
Directly run docker image to create a Container of nginx.
--cap-add all : it will add all capabilities, no need for change config file
-v: volumn to mount system file system with docker file system.(**THIS IS RESON WHY NGINX DOCKERFILE NEED UBUNTU IMAGE LOAD**)
/usr/local/nginx/logs: Nginx needs error.log to run
/user/local/nginx/conf: Nginx needs nginx.conf to run
-d: Run in background, this args cause running image will create Container
docker ps
ps -A | grep nginx
755 ? 00:00:00 popcorn-nginx
756 ? 00:00:00 popcorn-nginx
popcorn-notify 755 aarch64
popcorn-notify 756 aarch64
docker checkpoint create 4e6f433906d85a874acdc1b3138ffc9389e74e7120e11f5e0aa25dd08d3270f4 simple
./scripts/recode.sh 4e6f433906d85a874acdc1b3138ffc9389e74e7120e11f5e0aa25dd08d3270f4 simple aarch64
scp -r simple $target@x86_machine:~
ssh $target@ARM_machine
cp -r nginx_bin /app
cd nginx_bin
cp -r nginx /usr/local/
cp popcorn-nginx_aarch64 popcorn-nginx
docker build -t mynginx_arm .
# Likewise the capabilities and volumn mapping and port mapping can be done in hostconfig and config.v2.json file.
docker run --cap-add all -d -v /usr/local/nginx/logs/:/usr/local/nginx/logs/ -v /usr/local/nginx/conf/:/usr/local/nginx/conf/ mynginx_arm
10877d6d99969b4bdc0a4fc1dc144615cb1e0d1bbbb727324adc7538f473b394
Since we run image to create a container, so this time, we need stop it first.
docker container stop 10877d6d99969b4bdc0a4fc1dc144615cb1e0d1bbbb727324adc7538f473b394
Copy the transferred recoded checkpoint in /tmp to the sub-directory checkpoints inside the Container directory, then restart the Nginx Container on target Machine
cp -r ~/simple /var/lib/docker/containers/10877d6d99969b4bdc0a4fc1dc144615cb1e0d1bbbb727324adc7538f473b394/checkpoints
docker container start --checkpoint simple 10877d6d99969b4bdc0a4fc1dc144615cb1e0d1bbbb727324adc7538f473b394
docker ps