nginx ("engine x") is an HTTP web server, reverse proxy, content cache, load balancer, TCP/UDP proxy server, and mail proxy server.
Pull the latest version of this image from the Ghost registry. Pulling requires authentication — generate a token and run docker login first (see Authentication below).
The Ghost catalog is public to browse, but pulling images requires an account. Generate a pull token below (or from your Account → Tokens page) — you'll get a ready-to-paste docker login command, then docker pull works.
The username is generated automatically (it looks like robot$<project>+<auto-id>, not the name you typed) and is included in the docker login command above. The secret is shown only once when you create the token.
All Ghost images are signed with cosign. Verifying the signature before deployment ensures the image has not been tampered with.
Install cosign via brew install cosign or download from the Sigstore releases page.
Reference this image in your Dockerfile as a base layer:
This is a vendor-built FIPS-enabled image: its cryptography runs on FIPS 140-3 validated modules configured by the upstream vendor. You can inspect the image metadata:
| Standard | FIPS 140-3 |
| Crypto module | Vendor-configured validated modules |
| Cryptography | Validated modules only |
| Use case | Government, regulated industries, compliance workloads |
All examples in this guide use the public image. If you’ve mirrored the repository for your own use (for example, to your Docker Hub namespace), update your commands to reference the mirrored image instead of the public one.
For example:
registry.ghost-prod.alphabravo.io/ghost-base/<repository>:<tag><your-namespace>/dhi-<repository>:<tag>For the examples, you must first use docker login registry.ghost-prod.alphabravo.io to authenticate to the registry to pull the images.
To host some simple static content with this image, you can bind mount a directory of content to /usr/share/nginx/html
in the container. For example:
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>
Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount):
FROM registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>
COPY static-html-directory /usr/share/nginx/html
Place this file in the same directory as your directory of content ("static-html-directory"), then run these commands to build and start your container:
$ docker build -t some-content-nginx .
$ docker run --name some-nginx -d some-content-nginx
By default, this Nginx image listens on port 8080. To expose this port to the host, use the -p flag on docker run.
Assuming you've built the image as shown in the previous example, you can run:
$ docker run --name some-nginx -d -p 8080:8080 some-content-nginx
Then you can hit http://localhost:8080 or http://host-ip:8080 in your browser.
You can mount your configuration file, or build a new image with it.
If you wish to adapt the default configuration, you can use cat to output the default configuration file.
$ docker run --rm --entrypoint cat registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag> /etc/nginx/nginx.conf > nginx.conf
Then you can edit the contents in the new local file, and mount it into a new container.
$ docker run --name some-nginx -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro -d -p 8080:8080 registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>
Or, build a new image with your configuration file.
FROM registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>
COPY nginx.conf /etc/nginx/nginx.conf
Note: This feature is only available in the -dev variant of the image.
Out-of-the-box, Nginx doesn't support environment variables inside most configuration blocks. But the -dev variant of
this image includes an entrypoint function that will extract environment variables before Nginx starts.
Here is an example using a Compose file.
web:
image: registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>-dev
volumes:
- ./templates:/etc/nginx/templates
ports:
- "8080:8080"
environment:
- NGINX_HOST=foobar.com
- NGINX_PORT=8080
By default, this function reads template files in /etc/nginx/templates/*.template and outputs the result of executing
envsubst to /etc/nginx/conf.d.
So if you place templates/default.conf.template file, which contains variable references like this:
listen ${NGINX_PORT};
It outputs to /etc/nginx/conf.d/default.conf like this:
listen 8080;
This behavior can be changed via the following environment variables:
NGINX_ENVSUBST_TEMPLATE_DIR
/etc/nginx/templates)NGINX_ENVSUBST_TEMPLATE_SUFFIX
.template)NGINX_ENVSUBST_OUTPUT_DIR
envsubst is output (default: /etc/nginx/conf.d)/etc/nginx/templates/default.conf.template will be output with the filename /etc/nginx/conf.d/default.conf.To run Nginx in read-only mode, you will need to mount a Docker volume to every location where Nginx writes information.
The default Nginx configuration requires write access to /var/cache/nginx and /var/run. This can be easily
accomplished by running Nginx as follows:
$ docker run -d -p 8080:8080 --read-only -v $(pwd)/nginx-cache:/var/cache/nginx -v $(pwd)/nginx-pid:/var/run registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>
If you have a more advanced configuration that requires Nginx to write to other locations, simply add more volume mounts to those locations.
dev variants include the nginx-debug binary that produces verbose output when using higher log levels. It can be
used with simple CMD substitution:
$ docker run --name my-nginx -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>-dev nginx-debug -g 'daemon off;'
Similar configuration in compose.yaml may look like this:
web:
image: registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>-dev
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
command: [nginx-debug, '-g', 'daemon off;']
Note: This feature is only available in the -dev variant of the image.
A verbose entrypoint was added to the -dev variant. It provides information on what's happening during container
startup. You can silence this output by setting environment variable NGINX_ENTRYPOINT_QUIET_LOGS:
$ docker run -d -e NGINX_ENTRYPOINT_QUIET_LOGS=1 registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>-dev
| Feature | Non-hardened Nginx | Docker Hardened Nginx |
|---|---|---|
| Security | Standard base with common utilities | Minimal, hardened base with security patches |
| Shell access | Full shell (bash/sh) available | No shell in runtime variants unless needed to run the app |
| Package manager | apt/apk available | No package manager in runtime variants |
| User | Runs as root by default | Runs as nonroot user |
| Attack surface | Larger due to additional utilities | Minimal, only essential components |
| Debugging | Traditional shell debugging | Use Docker Debug or Image Mount for troubleshooting |
Ghost hardened images prioritize security through minimalism:
The hardened images intended for runtime don't contain a shell unless it's required for the application to run. Runtime images also typically don't include debugging tools. Common debugging methods for applications built with Docker Hardened Images include:
Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
For example, you can use Docker Debug:
docker debug <image-name>
or mount debugging tools with the Image Mount feature:
docker run --rm -it --pid container:my-container \
--mount=type=image,source=registry.ghost-prod.alphabravo.io/ghost-base/busybox,destination=/dbg,ro \
registry.ghost-prod.alphabravo.io/ghost-base/<image-name>:<tag> /dbg/bin/sh
Ghost hardened images come in different variants depending on their intended use.
Runtime variants are designed to run your application in production. These images are intended to be used either
directly or as the FROM image in the final stage of a multi-stage build. These images typically:
Build-time variants typically include dev in the variant name and are intended for use in the first stage of a
multi-stage Dockerfile. These images typically:
Switching to the hardened image does not require any special changes. You can use it as a drop-in replacement for the standard Nginx image in your existing workflows and configurations.
nginx:<tag>registry.ghost-prod.alphabravo.io/ghost-base/nginx:<tag>The following are common issues that you may encounter during migration.
The hardened images intended for runtime don't contain a shell unless it's required for the application to run, and typically don't include debugging tools. The recommended method for debugging applications built with Docker Hardened Images is to use Docker Debug to attach to these containers. Docker Debug provides a shell, common debugging tools, and lets you install other tools in an ephemeral, writable layer that only exists during the debugging session.
By default image variants intended for runtime, run as the nonroot user. Ensure that necessary files and directories are accessible to the nonroot user. You may need to copy files to different directories or change permissions so your application running as the nonroot user can access them.
Non-dev hardened images run as a nonroot user by default. As a result, applications in these images can't bind to
privileged ports (below 1024) when running in Kubernetes or in Docker Engine versions older than 20.10. To avoid issues,
configure your application to listen on port 1025 or higher inside the container, even if you map it to a lower port on
the host. For example, docker run -p 80:8080 my-image will work because the port inside the container is 8080, and
docker run -p 80:81 my-image won't work because the port inside the container is 81.
By default, image variants intended for runtime don't contain a shell unless it's required for the application to run.
Use dev images in build stages to run shell commands and then copy any necessary artifacts into the runtime stage. In
addition, use Docker Debug to debug containers with no shell.
Ghost hardened images may have different entry points than images such as Docker Official Images. Use docker inspect
to inspect entry points for Ghost hardened images and update your Dockerfile if necessary.