Docker Tutorial: Organizing the nginx container script to start a mounting directory

Start a temporary container without mounting it

docker run -d --name zxl-nginx  -p 80:80 nginx

Copy the configuration file from the container

docker cp zxl-nginx:/etc/nginx/nginx.conf /home/nginx/nginx.conf
docker cp zxl-nginx:/etc/nginx/conf.d /home/nginx/
docker cp zxl-nginx:/usr/share/nginx/html /home/nginx/

Delete temporary container

docker rm -f zxl-nginx

Restart a container with a mounted directory

docker run \
 -p 80:80 \
 --name nginx01 \
 -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf \
 -v /home/nginx/conf.d:/etc/nginx/conf.d \
 -v /home/nginx/logs:/var/log/nginx \
 -v /home/nginx/html:/usr/share/nginx/html \
 -d nginx:latest

Guess you like

Origin blog.csdn.net/a772304419/article/details/132913155