系统相关
首页 > 系统相关> > nginx-容器方式安装

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,vdb,usr,&&,local
来源: https://www.cnblogs.com/tanxiaojun/p/15366858.html