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