EXAMPLE
Background Steps
This example shows how to start a long-running container service in the background, run work against it, and tear it down — all from a workflow.
Try it out
- Install Atmos
- Try the example
Copy the example into a new directory and make it your own:
atmos init examples/background-steps
cd background-steps
Follow the README for prerequisites and next steps.
See it in action
RECORDED DEMO Real commands. Real output.
README.md2.2 KB
View on GitHubBackground container services
This example shows how to start a long-running container service in the background, run work against it, and tear it down — all from a workflow.
A container step with background: true starts detached and the workflow continues
to the next step. Atmos reuses the existing container lifecycle to supervise it:
- Readiness reuses the container
healthcheck:(underwith:). When a health check is configured, Atmos blocks until the service is healthy before the next step (the implicit readiness gate). An explicit{type: wait, for: [name]}(or{type: wait-all}) does the same on demand. - Teardown is an explicit
{type: cancel, for: [name]}step (stop + remove). Anything still running when the workflow ends is auto-torn-down — a service never exits on its own, so it is never "waited to exit".
Requires a container runtime (Docker or Podman).
Run it
cd examples/background-steps# Start nginx in the background, wait until healthy, use it, then cancel it.atmos workflow service -f background# Start redis + nginx in the background, wait-all, then tear both down.atmos workflow fanout -f background
How it maps to the syntax
- name: cachetype: containeraction: runbackground: true # start detached, keep goingwith: # all container params live under `with:`image: nginx:alpinehealthcheck: # the readiness gate (reuses the container health check)test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost/ || exit 1"]interval: 2sretries: 10- name: use-servicetype: shellcommand: ... # runs only after `cache` is healthy- type: cancelfor: cache # graceful teardown
See the parallel example for the complementary structured
concurrency (parallel/matrix) control steps.