Included Tools: OPM & LuaRocks
Several docker-openresty flavors come with package managers for OpenResty and Lua, making it easy to extend your application with community modules.
OPM (OpenResty Package Manager)
OPM is the official package manager for OpenResty, used for distributing both Lua and Nginx C modules.
Availability:
opm is included in most upstream-package-based flavors, particularly the -fat variants (e.g., bookworm-fat, bullseye-fat) and the RPM-based flavors (centos, fedora).
Usage:
-
alpine(source-built): Thealpineimage is minimal and does not includeopm's dependencies. To useopm, you must installcurlandperlfirst:FROM openresty/openresty:alpine RUN apk add --no-cache curl perl # Now you can use opm RUN opm get bungle/lua-resty-template -
Debian-based (
bullseye,bookworm): The standard images are minimal. To useopm, you can either use the-fatvariant or install theopenresty-opmpackage in a custom build:FROM openresty/openresty:bookworm RUN apt-get update && apt-get install -y openresty-opm RUN opm get bungle/lua-resty-template
LuaRocks
LuaRocks is the package manager for the Lua programming language. It is used to install pure Lua modules or C modules that need to be compiled.
Availability:
LuaRocks is included in the build-from-source flavors (bionic, focal, jammy, noble), the -fat variants (alpine-fat), and the RPM-based flavors (centos, fedora).
It is located at /usr/local/openresty/luajit/bin/luarocks.
Usage:
You can install modules (known as "rocks") in your own Dockerfile like so:
FROM openresty/openresty:jammy
# Install a Lua module for Redis
RUN /usr/local/openresty/luajit/bin/luarocks install lua-resty-redis
# Install a C-based module (requires build tools)
# The 'jammy' image already includes build-essential
RUN /usr/local/openresty/luajit/bin/luarocks install lpeg
LUA_PATH and LUA_CPATH
The images that include LuaRocks have the LUA_PATH and LUA_CPATH environment variables pre-configured. This ensures that Lua modules installed via LuaRocks can be found by require() in your OpenResty application without any extra configuration.