Package a static HTML site
A small example
FROM busybox:1.37WORKDIR /siteCOPY index.html .USER 10001:10001EXPOSE 8080CMD ["httpd", "-f", "-p", "127.0.0.1:8080", "-h", "/site"]HTML is delivered unchanged by this small server. COPY places the file in /site; httpd serves that directory, and -f keeps the server in the foreground. USER chooses an unprivileged numeric identity; verify the file is readable. Port 8080 avoids reliance on privileged low ports. The listener is container loopback only, so the probe runs in the same container using docker exec. EXPOSE is descriptive metadata, not a published host port. This BusyBox example is a learning server, not a hardened production web server. For real sites consider a maintained server, cache headers, TLS termination and accessibility. No compiler or frontend package manager is needed for this plain HTML page. In this recipe the bind address is explicitly 127.0.0.1; another container cannot reach this listener through its own loopback. Verify the approved BusyBox httpd supports the specified address syntax.
Try it in a local lab
Manual lab only; basic language familiarity is helpful, but every source file is supplied. Use a fresh authorized disposable Linux VM with blocked external egress, a local Engine and local Buildx docker driver. Check docker context show, docker version, docker buildx version and docker buildx ls. Verify the reviewed preloaded native base image named in the recipe, its digest, tool versions, inherited entrypoint, file permissions and required commands. Tags are mutable. Confirm all bm-v11 names and tags are unused. Stop if any input must be fetched or a builder is remote. --network none at build time constrains RUN, not all builder traffic. Runtime --network none leaves container loopback only. No public ports, credentials, host mounts or registry access. Execute separately, stop on unexpected failure, and dispose of the VM even if cleanup fails. All Docker results are predictions. Before contacting any Engine or builder, verify the effective endpoint of this exact command, including DOCKER_CONTEXT, DOCKER_HOST and builder overrides. Use only a reviewed fixture directory containing the listed inputs. Check the build exit status and record the loaded image ID before running; a failed build does not clear an older tag.
Open lab-fixtures/docker-application-packaging/01-static-site/ in the extracted archive. The Dockerfile and these files are supplied. Work on a disposable copy, not the original archive.
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>ByteMind demo</title></head><body><main><h1>Catalog ready</h1><p>Static files, one image.</p></main></body></html>docker build --load --network none --progress=plain -t bm-v11-static-site:lab .docker run -d --name bm-v11-static-site --pull=never --network none bm-v11-static-site:labCheck container state and logs first. For HTTP, try the bounded probe once, and if startup is still in progress repeat once after a short interval. If it still fails, stop and diagnose. For the worker, confirm its ready message before stopping.
docker exec bm-v11-static-site wget -T 3 -qO- http://127.0.0.1:8080/After the server is ready, expect the HTML containing Catalog ready. This demonstrates content delivery, not public connectivity. Detached startup is not readiness. Check the named container is running and inspect bounded logs if the first request fails. Retry the documented probe only within a 15-second startup budget; stop and diagnose if it still fails. Record response and command exit status.
Confirm names and tag belong to this lab. For a service, stop it if still running and remove only the named container. Then remove only this image tag without forcing. If a command fails, inspect state before continuing; do not remove unrelated objects. Dispose of the VM rather than clearing a shared cache.
docker stop -t 5 bm-v11-static-sitedocker rm bm-v11-static-sitedocker image rm bm-v11-static-site:labCommon mistake
Copying HTML into an image does not start a server. A foreground server and a readable document root are necessary.
Manual practice
Change the heading in a disposable copy. Predict the result before and after rebuilding the image. Explain why a source edit does not change a previously built image.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Package a static HTML site — Knowledge check
Apply the application packaging concept to a new scenario.
Which instruction places the page in the image?
Why run httpd in foreground?
Where is the probe performed?