| GitHub | DockerHub | Quay.io |
This is a static build/binary of NGINX.
Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license.
These container images can be used almost in the same way as the official images nginx/nginx-unprivileged:mainline-alpine (nginx:mainline-alpine):
- Docker Hub: nginx/nginx-unprivileged | GitHub: nginx/docker-nginx-unprivileged
- (Docker Hub: library/nginx | GitHub: nginx/docker-nginx)
However, they do not contain a shell and therefore no envsubst (for templates).
Images: ghcr.io/tob1as/static-nginx, docker.io/tobi312/static-nginx, quay.io/tobi312/static-nginx
| Tags | Description | Registries | Platforms |
|---|---|---|---|
latest, <version>, privileged, <version>-privileged |
privileged (root, port 80) |
all | linux/amd64, linux/arm64, linux/arm/v7 |
latest-unprivileged, <version>-unprivileged, unprivileged |
unprivileged (user 101, port 8080) |
all | linux/amd64, linux/arm64, linux/arm/v7 |
<version>-privileged-<date>.<commit>, <version>-unprivileged-<date>.<commit> |
unique (immutable) tag of a build | ghcr.io | linux/amd64, linux/arm64, linux/arm/v7 |
base-alpine, base-alpine-<version>, base-alpine-<version>-<date>.<commit> |
base image (only /nginx, see "Use in own image"), built on Alpine (musl) |
ghcr.io | linux/amd64, linux/arm64, linux/arm/v7 |
base-debian, base-debian-<version>, base-debian-<version>-<date>.<commit> |
base image, built on Debian (glibc) | ghcr.io | linux/amd64, linux/arm64 |
<version> = nginx version, e.g. 1.31.10; <date>.<commit> e.g. 20261123101500.1a2b3c4
Run NGINX container:
# privileged / root user
$ docker run --name some-nginx -p 8080:80 -v ${PWD}/html:/usr/share/nginx/html:ro -d docker.io/tobi312/static-nginx:latest
# unprivileged / nginx user
$ docker run --name some-nginx -p 8080:8080 -v ${PWD}/html:/usr/share/nginx/html:ro -d docker.io/tobi312/static-nginx:latest-unprivilegedOwn configuration (server blocks in /etc/nginx/conf.d/, main config /etc/nginx/nginx.conf):
$ docker run --name some-nginx -p 8080:8080 -v ${PWD}/conf.d:/etc/nginx/conf.d:ro -d docker.io/tobi312/static-nginx:latest-unprivilegedUseful commands:
# test configuration
$ docker run --rm -v ${PWD}/conf.d:/etc/nginx/conf.d:ro docker.io/tobi312/static-nginx:latest-unprivileged nginx -t
# reload configuration
$ docker exec some-nginx nginx -s reload
# show version and build options
$ docker run --rm docker.io/tobi312/static-nginx:latest nginx -VUse in own image:
# build on alpine:
COPY --from=ghcr.io/tob1as/static-nginx:base-alpine /nginx /
# build on debian:
COPY --from=ghcr.io/tob1as/static-nginx:base-debian /nginx /Notes for the base images:
/nginxcontains nginx incl. configs, html and log symlinks, but no/run(exists in Alpine/Debian) and no user: the defaultnginx.confusesuser nginx;, so create the user (UID/GID101like the official images), e.g.:- Alpine:
addgroup -g 101 -S nginx && adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx - Debian:
groupadd --system --gid 101 nginx && useradd --system --gid nginx --no-create-home --home /nonexistent --shell /bin/false --uid 101 nginx
- Alpine:
- CA certificates (
/etc/ssl/certs/ca-certificates.crt) are not part of/nginx, install them in your image if needed (packageca-certificates). base-debian: the static glibc binary also works without the glibc NSS libraries (e.g. inscratch, tested on amd64 and arm64): user lookups (/etc/passwd,/etc/group) and host name resolution (/etc/hosts, DNS) are part of libc since glibc 2.34. Only other NSS sources in/etc/nsswitch.conf(e.g. LDAP, systemd) need the NSS libraries, i.e. a Debian (glibc) based image.
- No
load_moduleneeded: the dynamic modules ofnginx:mainline-alpineare compiled in statically:ngx_http_acme_module,ngx_http_geoip_module/ngx_stream_geoip_module,ngx_http_image_filter_module,ngx_http_xslt_filter_module,ngx_http_js_module/ngx_stream_js_module(njs). Existing configs withload_moduledirectives must be adjusted (remove the directives), otherwise nginx does not start. - GeoIP: supports legacy (
.dat) and GeoIP2/MMDB (.mmdb) databases. - njs: QuickJS engine available (
js_engine qjs;). - No shell and no entrypoint script (base image
scratch):- no
/docker-entrypoint.d/scripts, no templates in/etc/nginx/templates(envsubst),NGINX_ENTRYPOINT_*variables have no effect docker exec ... shis not possible- no
curl/wgetfor container healthchecks (use e.g. a TCP check or an external check)
- no
- Unprivileged images (like
nginx/nginx-unprivileged):- run as user
101(group0), listen on port8080(HTTPS example indefault.conf:8443) - PID file
/tmp/nginx.pid, temp paths (proxy_temp,client_temp, ...) in/tmp
- run as user
- CA certificates:
/etc/ssl/certs/ca-certificates.crt(from Alpine), also used as OpenSSL default (/etc/ssl/cert.pem), e.g. foracme_issuerorproxy_ssl_verify.
Use the unprivileged image:
- Arbitrary UIDs with GID
0are supported (/etc/nginx,/var/cache/nginxand/runare group-writable). - With
readOnlyRootFilesystem: truemount anemptyDirto/tmp(PID file, temp paths) and - if ACME is used - to/var/cache/nginx(default ACMEstate_path).
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}Local build (versions: see ARG in the base Dockerfiles, can be overridden with --build-arg).
The privileged/unprivileged images use the base image ghcr.io/tob1as/static-nginx:base-alpine[-<NGINX_VERSION>] (pulled from ghcr.io, if not available locally):
# base image
$ docker build --progress=plain --target binary --build-arg NGINX_VERSION=1.31.10 -t ghcr.io/tob1as/static-nginx:base-alpine-1.31.10 -f static-nginx.base-alpine.Dockerfile .
# privileged / unprivileged image
$ docker build --progress=plain --target binary --build-arg NGINX_VERSION=1.31.10 -t local/static-nginx:latest -f static-nginx.privileged.Dockerfile .
$ docker build --progress=plain --target binary --build-arg NGINX_VERSION=1.31.10 -t local/static-nginx:latest-unprivileged -f static-nginx.unprivileged.Dockerfile .CI (GitHub Actions):
- runs on push if a Dockerfile or the workflow changed, or manually ("Run workflow")
- the latest versions of nginx and all dependencies are determined at workflow start and passed as build args
- Alpine: base image, privileged and unprivileged images; Debian: only base image