docker安装nginx并进行-v挂载

运行一个nginx容器:

docker run -d -p 80:80 --name nginx zhangxueliang2020/nginx:v1.19.3

将nginx容器中的配置文件nginx.conf拷贝到本地:

root@debian:/home/zxl/workspace/docker/nginx# docker cp nginx:/etc/nginx/nginx.conf /home/zxl/workspace/docker/nginx/conf/nginx.conf
root@debian:/home/zxl/workspace/docker/nginx# ls conf
nginx.conf

进行目录及配置文件的挂载:

docker run -d -p 80:80 --name nginx -v /home/zxl/workspace/docker/nginx/www:/usr/share/nginx/html -v /home/zxl/workspace/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /home/zxl/workspace/docker/nginx/conf/conf.d:/etc/nginx/conf.d -v /home/zxl/workspace/docker/nginx/logs:/var/log/nginx zhangxueliang2020/nginx:v1.19.3

一定要有nginx.conf配置文件,否则报错。

 

上一篇:【题解】Luogu-P3301 [SDOI2013]方程


下一篇:[转]SpringMVC Controller介绍及常用注解