Skip to content

CICD-124 · Run a network-bound smoke check ​

Encyclopedia · Docker runtime and Compose · All snippets

Previous · CICD-123 · Next · CICD-125

1. Where it fits ​

  • Placement Bash run step following checkout, or equivalent lab terminal.
  • Prerequisites disposable Docker or Compose project with example web service.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
id=$(docker run -d -p 127.0.0.1:18000:8000 web:ci)
trap 'docker rm -f "$id" >/dev/null' EXIT
curl -fsS --retry 10 --retry-connrefused --retry-delay 1 http://127.0.0.1:18000/healthz

3. How it works ​

The command starts a container from the selected image under its declared network and resource options. The request checks the selected HTTP interface. Timeouts limit waiting, and an explicit exit or payload condition determines pass and fail.

The running image has to answer the same request CI will test.

flowchart TD
  N1["Image"]
  N2["Start test container"]
  N1 --> N2
  N3{"Health responds"}
  N2 --> N3
  N4["Pass smoke test"]
  N3 -->|Yes| N4
  N5["Fail smoke test"]
  N3 -->|Deadline| N5
  N6["Remove test container"]
  N4 --> N6
  N5 --> N6

4. Verify the result ​

Use a unique port or bounded per-run network when jobs share a host.

Validation syntax-validated (Bash parse). Status definitions.