管理。
强烈建议使用基于上游的镜像以获得最佳支持。为保证稳定性,建议将镜像固定到完整标签,例如1.13.6.2-0-xenial。
docker-openresty是Docker工具,用于部署OpenResty([***]
Docker是容器管理平台。
OpenResty是一个成熟的Web应用服务器,通过捆绑标准Nginx核心、大量第三方Nginx模块及其外部依赖构建而成。
如果默认构建满足需求,可直接使用https://hub.docker.com/r/openresty/openresty/%E4%B8%8A%E7%9A%84openresty%E9%95%9C%E5%83%8F%E3%80%82%E5%8F%AF%E7%94%A8%E9%95%9C%E5%83%8F%E6%A0%87%E7%AD%BE%E5%B7%B2%E5%9C%A8%E6%9C%AC%E6%96%87%E6%A1%A3%E9%A1%B6%E9%83%A8%E5%88%97%E5%87%BA%E3%80%82
bashdocker run [选项] openresty/openresty:stretch-fat
*[选项]*包括-p(端口映射)、-v(卷挂载)、-d(后台运行)等。
docker-openresty会将/usr/local/openresty/nginx/logs/access.log和error.log分别符号链接到/dev/stdout和/dev/stderr,以确保Docker日志功能正常。如果在nginx.conf中修改日志路径,需将新路径也进行符号链接。Windows镜像不支持此功能。
Docker工具会安装自带的https://github.com/openresty/docker-openresty/blob/master/nginx.conf%E3%80%82%E5%A6%82%E9%9C%80%E7%9B%B4%E6%8E%A5%E8%A6%86%E7%9B%96%EF%BC%8C%E5%8F%AF%E5%9C%A8%E8%87%AA%E5%AE%9A%E4%B9%89Dockerfile%E4%B8%AD%E6%9B%BF%E6%8D%A2%E6%88%96%E9%80%9A%E8%BF%87%E5%8D%B7%E6%8C%82%E8%BD%BD%E5%AE%9E%E7%8E%B0%E3%80%82
对于Linux镜像,nginx.conf包含指令include /etc/nginx/conf.d/*.conf;,因此该目录下的所有Nginx配置都会被包含。https://github.com/openresty/docker-openresty/blob/master/nginx.vh.default.conf%E5%8C%85%E5%90%AB%E5%8E%9F%E5%A7%8BOpenResty%E9%85%8D%E7%BD%AE%EF%BC%8C%E4%BC%9A%E8%A2%AB%E5%A4%8D%E5%88%B6%E5%88%B0%60/etc/nginx/conf.d/default.conf%60%E3%80%82
可直接覆盖default.conf或通过卷挂载/etc/nginx/conf.d目录到自定义配置:
bashdocker run -v /my/custom/conf.d:/etc/nginx/conf.d openresty/openresty:alpine
使用windows镜像时,可直接修改主配置:
bashdocker run -v C:/my/custom/nginx.conf:C:/openresty/conf/nginx.conf openresty/openresty:windows
从1.11.2.2版本开始,Linux版OpenResty包含https://github.com/openresty/opm#readme%EF%BC%8C%E4%BD%8D%E4%BA%8E%60/usr/local/openresty/bin/opm%60%E3%80%82
除alpine和stretch外,所有镜像均内置opm。
在alpine镜像中使用opm需安装curl和perl包(默认未包含以减小镜像体积),可通过以下命令安装:apk add --no-cache curl perl。
在stretch镜像中使用opm,可使用stretch-fat镜像或在自定义构建中安装openresty-opm包(安装自定义opm包时也需此步骤),示例见https://github.com/openresty/docker-openresty/blob/master/stretch/Dockerfile.opm_example%E3%80%82
LuaRocks包含在alpine-fat、centos和xenial版本中。alpine版本中未包含,因通常需要构建系统,为保持精简而排除。
LuaRocks路径为/usr/local/openresty/luajit/bin/luarocks。可在依赖的Dockerfile中添加包:
bashRUN /usr/local/openresty/luajit/bin/luarocks install <rock>
envsubst工具在除alpine和windows外的所有镜像中可用;该工具也包含在Nginx Docker镜像中,用于将环境变量模板化到配置文件。
Docker Hub目前不支持ARM构建,因此armhf-xenial镜像不可用(见https://github.com/openresty/docker-openresty/pull/26%EF%BC%89%E3%80%82%E5%8F%AF%E4%BD%BF%E7%94%A8%E6%9E%84%E5%BB%BA%E5%8F%82%E6%95%B0%60RESTY_DEBIAN_BASE%60%E8%87%AA%E8%A1%8C%E6%9E%84%E5%BB%BA%EF%BC%9A
bashdocker build -f xenial/Dockerfile --build-arg "RESTY_DEBIAN_BASE=armv7/armhf-ubuntu" .
默认情况下,OpenResty会在构建机器支持时启用SSE4.2优化。在不支持SSE4.2的机器上运行会出现https://github.com/openresty/docker-openresty/issues/39%E3%80%82**%E5%9B%A0%E6%AD%A4%E6%89%80%E6%9C%89Docker Hub镜像均要求SSE4.2支持**。可从源码构建自定义镜像并显式禁用SSE4.2,使用构建参数:
bashdocker build -f xenial/Dockerfile --build-arg "RESTY_CONFIG_OPTIONS_MORE=--with-luajit-xcflags='-mno-sse4.2'" .
所有镜像版本均使用OpenSSL 1.1.0h。注意opm和LuaRocks包的兼容性,需确保使用相同OpenSSL版本。
1.13.6.2-alpine基于OpenSSL 1.0.2.k构建,因Alpine上存在构建问题。
容器停止时会向Nginx发送SIGQUIT信号,使其优雅停止(即完成活跃连接处理)。Docker默认使用SIGTERM,会立即终止活跃连接。注意:若配置监听UNIX域套接字,由于nginx bug #753,需在关闭时手动删除套接字文件。
Dockerfile的CMD中使用-g "daemon off;"指令,以确保容器创建后Nginx后台进程持续运行。若在nginx.conf中添加该指令,则docker run需显式调用openresty(Windows镜像使用nginx):
bashdocker run [选项] openresty/openresty:xenial openresty
调用其他CMD(如resty工具):
bashdocker run [选项] openresty/openresty:xenial resty [script.lua]
注意 alpine镜像不包含resty工具所需的perl和ncurses包。
可通过克隆仓库并使用指定Dockerfile运行docker build来构建和自定义此Docker镜像:
bashgit clone https://github.com/openresty/docker-openresty.git cd docker-openresty docker build -t myopenresty -f xenial/Dockerfile . docker run myopenresty
提供以下基础系统的Dockerfile,通过-f指定路径:
alpine/Dockerfile)alpine-fat/Dockerfile)xenial/Dockerfile)过去支持更多构建版本,已精简,旧Dockerfile归档于https://github.com/openresty/docker-openresty/tree/master/archive%E6%96%87%E4%BB%B6%E5%A4%B9%E3%80%82
可通过--build-arg CLI参数设置以下构建时选项:
bashdocker build --build-arg RESTY_J=4 -f xenial/Dockerfile .
| 键 | 默认值 | 描述 |
|---|---|---|
| RESTY_IMAGE_BASE | "ubuntu" / "alpine" | 构建基础的Debian或Alpine Docker镜像 |
| RESTY_IMAGE_TAG | { "xenial", "bionic" } / "3.8" | 构建基础的Debian或Alpine Docker镜像标签 |
| RESTY_VERSION | 1.13.6.2 | OpenResty版本 |
| RESTY_LUAROCKS_VERSION | 2.4.4 | LuaRocks版本 |
| RESTY_OPENSSL_VERSION | 1.1.0i / 1.0.2p | OpenSSL版本 |
| RESTY_PCRE_VERSION | 8.42 | PCRE版本 |
| RESTY_J | 1 | 构建并行度(-jN) |
| RESTY_CONFIG_OPTIONS | "--with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-ipv6 --with-mail --with-mail_ssl_module --with-md5-asm --with-pcre-jit --with-sha1-asm --with-stream --with-stream_ssl_module --with-threads" | 传递给OpenResty ./configure脚本的选项 |
| RESTY_CONFIG_OPTIONS_MORE | "" | 传递给OpenResty ./configure脚本的额外选项 |
| RESTY_ADD_PACKAGE_BUILDDEPS | "" | 构建时需安装的额外包(安装后移除) |
| RESTY_ADD_PACKAGE_RUNDEPS | "" | 运行时需安装的额外包(不移除) |
| RESTY_EVAL_PRE_CONFIGURE | "" | 执行OpenResty ./configure前运行的命令(如克隆扩展仓库,需同时在RESTY_CONFIG_OPTIONS_MORE中添加相应参数) |
| RESTY_EVAL_POST_MAKE | "" | make install后运行的命令 |
这些从源码构建的版本默认包含以下模块,可通过上述自定义构建选项增减:
OpenResty现已提供RPM包。centos镜像使用这些RPM而非从源码构建。
可通过克隆仓库并使用指定Dockerfile构建和自定义:
centos/Dockerfile)可通过--build-arg CLI参数设置:
bashdocker build --build-arg RESTY_RPM_FLAVOR="-debug" centos
| 键 | 默认值 | 描述 |
|---|---|---|
| RESTY_IMAGE_BASE | "centos" | 构建基础的CentOS Docker镜像 |
| RESTY_IMAGE_TAG | "7" | 构建基础的CentOS Docker镜像标签 |
| RESTY_LUAROCKS_VERSION | 2.4.4 | LuaRocks版本 |
| RESTY_RPM_FLAVOR | "" | OpenResty包版本,可能为"-debug"或"-valgrind" |
| RESTY_RPM_VERSION | 1.13.6.2-1.el7.centos | 要安装的OpenResty包版本 |
| RESTY_RPM_ARCH | x86_64 | 要安装的OpenResty包架构 |
OpenResty现已提供Debian包(DEB)。stretch镜像使用这些DEB而非从源码构建。
可基于此派生自定义Docker镜像以安装自己的包。示例见https://github.com/openresty/docker-openresty/blob/master/stretch/Dockerfile.opm_example%E5%92%8Chttps://github.com/openresty/docker-openresty/blob/master/stretch/Dockerfile.luarocks_example%E3%80%82
可通过克隆仓库并使用指定Dockerfile构建和自定义:
stretch/Dockerfile)可通过--build-arg CLI参数设置:
bashdocker build --build-arg RESTY_DEB_FLAVOR="-debug" -f stretch/Dockerfile .
| 键 | 默认值 | 描述 |
|---|---|---|
| RESTY_IMAGE_BASE | "debian" | 构建基础的Debian Docker镜像 |
| RESTY_IMAGE_TAG | "stretch-slim" | 构建基础的Debian Docker镜像标签 |
| RESTY_DEB_FLAVOR | "" | OpenResty包版本,可能为"-debug"或"-valgrind" |
| RESTY_DEB_VERSION | "=1.13.6.2-1~stretch1" | Debian包版本,前缀为= |
可通过克隆仓库并使用指定Dockerfile构建和自定义:
以下是 ginolegaltechparis/openresty 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。




探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务