nginx-容器方式安装

2021/10/5 7:12:36

本文主要是介绍nginx-容器方式安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、Pull
docker pull qys123888/alpine-nginx-image:latest
2、Running
docker run -d --restart=always -p 80:80 -p 443:443 --name nginx qys123888/alpine-nginx-image:latest
3、Webroot|Confpath|Logspath
/usr/local/nginx/html
/usr/local/nginx/conf
/usr/local/nginx/logs
4、Bash-demo
tee ./nginx.sh <<-'EOF'
#!/bin/bash
docker rm -f nginx
rm -rf /vdb/nginx/* -rf && \
mkdir /vdb/nginx -p && \
docker run -d --restart=always --name nginx qys123888/alpine-nginx-image:latest sleep 3600 && \
docker cp nginx:/usr/local/nginx/conf /vdb/nginx/conf && \
docker cp nginx:/usr/local/nginx/html /vdb/nginx/html && \
docker cp nginx:/usr/local/nginx/logs /vdb/nginx/logs && \
docker rm -f nginx && \
chmod -R 777 /vdb/nginx && \
docker run -d --restart=always \
-p 80:80 \
-p 443:443 \
-v /vdb/nginx/conf:/usr/local/nginx/conf \
-v /vdb/nginx/html:/usr/local/nginx/html \
-v /vdb/nginx/logs:/usr/local/nginx/logs \
--name nginx \
qys123888/alpine-nginx-image:latest;
EOF

chmod +x ./nginx.sh && \
./nginx.sh;
4、 Reload
docker exec -it nginx nginx_reload
5、Get-version
docker exec -it nginx nginx -v
nginx version: BUILD20210827055300/1.21.1



这篇关于nginx-容器方式安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程