Docker 安装nginx并挂载目录


最近在弄青龙面板,用ginx弄下域名,简单记录下

先拉取nginx镜像

docker pull nginx

2、查看是否拉取成功

docker images

3、使用命令在源主机上新建文件夹

mkdir -p nginx/{conf,html,log}

4、启动临时nginx

docker run -d --name nginx_test nginx

5、拷贝需要挂载的文件

docker cp nginx_test:/etc/nginx/conf.d /root/nginx/conf

docker cp nginx_test:/etc/nginx/nginx.conf /root/nginx/conf/nginx.conf

docker cp nginx_test:/usr/share/nginx/html/index.html /root/nginx/html/index.html

6、删除临时nginx

docker rm -f nginx_test

7、创建挂载的nginx

docker run -d -p 80:80 --name nginx \
-v /root/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/nginx/html/index.html:/usr/share/nginx/html/index.html \
-v /root/nginx/log:/var/log/nginx \
nginx

验证:机器地址出现下图就可以了

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM