Docker 部署 OpenResty

Docker OpenResty DevOps About 871 words

搜索镜像

docker search openresty/openresty

拉取镜像

版本号可以去官网查看:https://hub.docker.com/r/openresty/openresty

docker pull openresty/openresty:1.19.9.1-centos7

nginx.conf

nginx.conf文件位于容器内的/usr/local/openresty/nginx/conf中。

端口配置

server { 
    listen 80;
    location / {
        root   html;
        index  index.html index.htm;
    }
}

创建容器

docker run -d \
--name=openresty \
-p 80:80 \
-v $PWD/openresty/conf/conf.d:/etc/nginx/conf.d \
-v $PWD/openresty/logs:/usr/local/openresty/nginx/logs \
-v $PWD/openresty/html:/usr/local/openresty/nginx/html \
openresty/openresty:1.19.9.1-centos7

可能出现的错误

WARNING: IPv4 forwarding is disabled. Networking will not work.

开启ipv4转发

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
systemctl restart network

进入容器

docker exec -it openresty bash

重启

docker exec -it openresty nginx -s reload

参考链接

https://github.com/openresty/docker-openresty

Views: 4,169 · Posted: 2022-02-01

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh