Container image and config paths
Separate the image, container and mounted files
An image packages a particular filesystem and executable; a container runs processes from it with its own writable layer and runtime settings. A mount can hide a file supplied by the image. For example, mounting a reviewed nginx.conf at /etc/nginx/nginx.conf replaces the visible file, without altering the underlying image. Use an official image from a trusted source, inspect its architecture and build features, and select a patched release. A tag can move; a digest identifies a particular manifest or multi-platform index. A digest does not certify security. The following is a schematic reference, not a real digest.
nginx:<reviewed-release>-alpinenginx@sha256:<verified-64-hex-digest>Keep the runtime writable paths explicit
An unprivileged process needs a high port and permission to write its PID and temporary data. Rootless Docker describes the daemon and container isolation model; a nonroot container user is a different control. Our fixture explicitly selects UID/GID 101, bypasses the image entrypoint, and puts writable paths under /tmp, a bounded tmpfs. The configuration is mounted read-only. Check the actual image can run with this identity, read its libraries, and write its log streams. Do not repair permissions by broadening host access.
pid /tmp/nginx.pid;error_log stderr;events { worker_connections 128; }http { client_body_temp_path /tmp/client; proxy_temp_path /tmp/proxy; fastcgi_temp_path /tmp/fastcgi; uwsgi_temp_path /tmp/uwsgi; scgi_temp_path /tmp/scgi; server { listen 8080; return 200 "ready\n"; }}Separate startup substitution from request variables
Some official image entrypoints generate configuration files from templates using envsubst before Nginx starts. That is text preprocessing, not Nginx request-time variable evaluation. An unrestricted substitution may replace variables that should survive, and a read-only output directory may prevent generation. When using the reviewed image entrypoint, inspect its template paths and filter behavior for the selected digest. With a custom preprocessing step explicitly allow only application settings, validate their values and inspect the rendered file. Here APP_PORT must be a validated numeric high port; $uri must remain literal for Nginx. The lab avoids this preprocessing entirely.
APP_PORT=8080 envsubst '${APP_PORT}' < server.conf.template > rendered.confRun a configuration check in the same image
Validate the exact image and mounted files before starting services. The following command assumes the provided lab, an approved Docker context, and preloaded reviewed image. Unlike a host nginx -t, it checks the image binary and paths. It may still require network name resolution for a proxy config, so use the backend-first sequence in the lab. Syntax success does not prove HTTP behavior.
docker compose -p bm-nginx48 run --rm --no-deps edge -tUse the Chapter 48 manual practice and lab. Snippets are illustrative; Docker and image execution were not available during authoring. The fixture requires an approved isolated Docker environment and a locally preloaded verified digest.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Container image and config paths
Assess decisions from the lesson and original lab.
What does an image digest identify?
Why place PID and temporary files under /tmp in this fixture?
Which expression should survive template preprocessing?
What does nonroot container execution establish?
Why test the actual image rather than only the host binary?