
communitycloud/openresty本镜像为最小化的Openresty部署方案,通过容器内编译构建,避免污染基础环境,并移除调试符号及非必要文件,最终镜像体积仅约13.43MB。镜像包含Openresty核心运行组件、LuaJIT环境及必要依赖库,适用于对资源占用敏感的生产环境。
http_ssl_module、http_gzip_static_module、http_gunzip_module、http_realip_module等pcre及pcre-jit支持、ipv6协议http_geoip_module(IP地理位置)、http_postgres_module(PostgreSQL集成)、http_secure_link_module(安全链接)resty系列Lua库(如redis、mysql、websocket等客户端)scratch基础镜像,无冗余依赖使用专用构建容器,挂载Docker socket以实现镜像构建:
bashdocker run --rm \ --name resty-builder \ --hostname resty-builder \ -v /var/run/docker.sock:/var/run/docker.sock \ -it communitycloud/docker-builder
在构建容器内添加Postgres源并安装编译工具:
bashecho "deb [***] jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && apt-get update && DEBIAN_FRONTEND=noninteractive \ && apt-get install -y wget ca-certificates sudo \ && wget --quiet -O - [***] | sudo apt-key add - \ && apt-get update \ && apt-get install -y build-essential curl libreadline-dev libncurses5-dev \ libpcre3-dev libssl-dev lua5.2 luarocks perl tree \ libgeoip-dev libpq-dev
下载源码并配置编译选项(指定安装路径、模块及运行时路径):
bashwget [***] \ && tar -xzf ngx_openresty-*.tar.gz \ && rm -f ngx_openresty-*.tar.gz \ && cd ngx_openresty-* \ && ./configure \ --with-http_ssl_module \ --with-pcre \ --with-pcre-jit \ --with-ipv6 \ --with-http_geoip_module \ --with-http_gzip_static_module \ --with-http_gunzip_module \ --with-http_realip_module \ --with-http_spdy_module \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_sub_module \ --with-http_postgres_module \ --with-http_secure_link_module \ --with-sha1=/usr/include/openssl \ --with-md5=/usr/include/openssl \ --prefix=/opt/openresty \ --sbin-path=/opt/openresty/sbin/nginx \ --conf-path=/etc/openresty/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_temp \ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ && make \ && make install \ && cd .. \ && rm -rf ngx_openresty-* \ && ldconfig
创建用户配置并移除调试符号:
bash# 创建用户文件 mkdir /opt/etc \ && echo 'nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin' > /opt/etc/passwd \ && echo 'nogroup:x:65534:' > /opt/etc/group \ && echo 'nobody:*:***:0:99999:7:::' > /opt/etc/shadow \ && echo 'nogroup:*::' > /opt/etc/gshadow # 移除调试符号 find /opt -type f -not -name "*.lua" -and -not -name "*.html" -exec strip {} \; 2>/dev/null
收集Openresty核心文件及运行时依赖库:
bash# 打包Openresty核心 cd / \ && tar cf resty.tar \ /opt/openresty/luajit/share/luajit-2.1.0-alpha/jit/ \ /opt/openresty/lualib/ \ /opt/openresty/nginx/ \ /opt/openresty/sbin/ # 收集动态依赖库 ldd /opt/openresty/sbin/nginx \ | awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' \ | sed 's/ /\n/g; s/_at\n/_at /g' \ | tar rhf resty.tar -T - # 添加额外系统依赖 cd /opt \ && tar rhf /resty.tar /lib/x86_64-linux-gnu/libnss_compat.so.2 \ /lib/x86_64-linux-gnu/libnss_files.so.2 \ /lib/x86_64-linux-gnu/libnsl.so.1 \ /lib/x86_64-linux-gnu/libnss_nis.so.2 \ /usr/lib/ssl/openssl.cnf /etc/ld.so.cache \ /etc/localtime /etc/nsswitch.conf \ etc/passwd etc/shadow etc/group etc/gshadow
创建Dockerfile并构建镜像:
bashmkdir -p /images/openresty && cp /resty.tar /images/openresty \ && cd /images/openresty \ && cat > Dockerfile <<EOF FROM scratch ADD resty.tar / VOLUME ["/var/log/nginx","/var/cache/nginx","/var/run"] EXPOSE 80 443 ENTRYPOINT ["/opt/openresty/sbin/nginx"] CMD ["-V"] EOF docker build -t communitycloud/openresty:1.7.7.2 . \ && docker tag communitycloud/openresty:1.7.7.2 communitycloud/openresty:latest
bashdocker run -d -p 80:80 --name openresty communitycloud/openresty:latest
bashdocker run -d -p 80:80 -p 443:443 \ -v $(pwd)/nginx.conf:/etc/openresty/nginx.conf \ -v $(pwd)/logs:/var/log/nginx \ --name openresty communitycloud/openresty:latest
bashdocker run --rm communitycloud/openresty:latest -V
最终镜像包含以下核心目录:
/opt/openresty:Openresty主目录(含sbin/nginx可执行文件、lualib Lua库)/lib、/lib64、/usr/lib:运行时依赖库/etc:用户配置文件(passwd、group等)/var/log/nginx(日志)、/var/cache/nginx(缓存)、/var/run(进程文件)



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