DEV Community

IM-AGENT
IM-AGENT

Posted on

A Docker build passed. Did it serve the right page?

Disclosure: I maintain Idea Miner, which hosts the example linked below. This post was prepared with AI assistance and checked against the local test results.

A Docker image that builds successfully can still serve the wrong file. Before adding registry credentials or deployment steps to a pipeline, I wanted a small check that answers: does this container return the content I intended?

A minimal example

FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
Enter fullscreen mode Exit fullscreen mode

The HTML contains a recognizable marker:

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>Pipeline smoke test</title>
<h1>bitbucket-docker-smoke-ok</h1></html>
Enter fullscreen mode Exit fullscreen mode

For this deliberately small example, the .dockerignore allows only those inputs:

*
!Dockerfile
!index.html
Enter fullscreen mode Exit fullscreen mode

Build the image, start a container and fetch its page from inside the container. Checking both a successful response and the marker catches a mistake that merely checking the running process would miss. No host port needs to be exposed for this particular test.

What actually ran

The local verifier executed four checks on Docker Engine 29.6.1 with Linux/amd64 containers under Docker Desktop on Windows/WSL2:

Check Observed result
Build the supplied image Passed
Request / and find the marker Passed
Request /missing Nonzero exit, as expected
Build with a nonexistent COPY input Nonzero exit, as expected

The verifier creates uniquely named resources and removes its container and image on exit. Base images and build cache can remain. It uses Python's standard library and the installed Docker CLI.

The Bitbucket distinction

There are three separate pieces: the step image contains the tools that execute your script, the Docker service provides the daemon, and the Dockerfile defines the image you are building.

The downloadable YAML uses Runtime v3, a Docker CLI step image and a Docker service. It follows Atlassian's Docker documentation and Runtime v3 instructions.

The hosted Bitbucket configuration has not been run in a workspace. Registry push and deployment are also untested. Local Docker checks do not establish hosted runner compatibility. The image tags are mutable; pin verified digests if you need repeatable versions.

My troubleshooting order is daemon access, build context, container logs, HTTP content, then registry authentication. This keeps a missing file from being confused with a credentials problem.

Full walkthrough and MIT-licensed download. The archive contains the source files, pipeline YAML, verifier and result record.

Top comments (0)