docker for nginx(1.16.0)
1?创建nginx
docker run –name nginx \
-p 80:80 \
-m 2048m \
–net=host \
–privileged=true \
-v /home/work/nginx/html:/usr/share/nginx/html \
-v /home/work/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/work/nginx/logs:/var/log/nginx \
-d nginx:1.16.0
–restart=always \ 不要重启功能
使用主机模式
2?刷新nginx配置
docker exec -it nginx /usr/sbin/nginx -s reload
docker exec -it nginx /usr/sbin/nginx -s stop
3?nginx内部工作目录
etc/nginx/nginx.conf
/usr/lib/nginx
/usr/sbin/nginx
/usr/share/doc/nginx
/usr/share/nginx
/var/cache/nginx
/var/log/nginx
4?从镜像获的默认配置文件nginx.conf,这个配置文件跟官网的配置文件不一样
docker run –name tmp-nginx-container -d nginx
docker cp tmp-nginx-container:/etc/nginx/nginx.conf /host/path/nginx.conf
docker rm -f tmp-nginx-container