Mar*_*ian 7 lua nginx docker alpine-linux
我希望在启用了Lua模块的情况下为nginx提供精简的Docker镜像.如何基于Alpine linux创建这个?
Mar*_*ian 15
这是一个Dockerfile
:
FROM alpine:3.6
RUN apk add --no-cache nginx-mod-http-lua
# Delete default config
RUN rm -r /etc/nginx/conf.d && rm /etc/nginx/nginx.conf
# Create folder for PID file
RUN mkdir -p /run/nginx
# Add our nginx conf
COPY ./nginx.conf /etc/nginx/nginx.conf
CMD ["nginx"]
Run Code Online (Sandbox Code Playgroud)
安装nginx-mod-http-lua
包也将安装nginx
和luajit
,等等.
该nginx.conf
至少应包含这样的:
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
pcre_jit on;
events {
worker_connections 1024;
}
daemon off;
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
FROM nginx:1.15-alpine
RUN mkdir -p /run/nginx
RUN apk add --no-cache nginx-mod-http-lua
COPY nginx_conf/ /etc/nginx/ # Your nginx conf
COPY lua/ /etc/lua/ # Your lua files
Run Code Online (Sandbox Code Playgroud)
nginxconf 的第一行:
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
pcre_jit on;
Run Code Online (Sandbox Code Playgroud)
use*_*097 -4
你看看 Docker Hub
你会发现一个 Nginx 镜像,基于 Alpine Linux,支持 Lua
一些例子
https://hub.docker.com/r/ilagnev/alpine-nginx-lua/
或者
https://hub.docker.com/r/firesh/nginx-lua/
查看 Dockerfile 了解更多详细信息