Skip to lesson
supraj.dev THE ENGINEERING HANDBOOKS
LEARN / BUILD / VERIFY2026 edition · checked 06 Oct

CHAPTER 15 / 30 · Capabilities

Build a Compose stack inside the boundary

Run a small multi-service workload through the private Engine and keep each port layer explicit.

4 min readWorked exerciseInterview practice

What you will build

A local-only web-and-cache teaching stack. Use synthetic data and a disposable mountless shell sandbox. This exercise does not use cloud compute or publish a public endpoint.

The mechanism at a glance
  1. Compose specification
  2. Private guest Engine
  3. Service network
  4. Guest port to host loopback

Conceptual flow. Follow the lesson for prerequisites, exact commands and verification limits.

Read the mechanism

Compose groups services, networks and volumes under one project. In this lab all services run through one sandbox’s private Engine. Service names resolve within the Compose network; they do not create a direct network between independent sandboxes.

There are three addresses to track: the container’s listening port, the port published into the guest, and the guest port forwarded to your host. Confusing them is a common reason a service appears healthy internally but cannot be reached from the browser.

A named volume belongs to the Engine’s storage lifecycle. Removing a service container is not the same as removing its volume, and deleting the entire sandbox is a broader operation.

Worked lab · two services, one boundary

Create a compose.yaml containing:

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
  cache:
    image: redis:alpine
    command: ["redis-server", "--save", "", "--appendonly", "no"]

These official-image tags are convenient for a first lab but mutable. For reproducible later runs, record the resolved digests and replace tags with your verified immutable references.

Transfer the file and start the stack:

sbx create --name handbook-compose --skills off shell
sbx cp ./compose.yaml handbook-compose:/home/agent/workspace/compose.yaml
sbx exec handbook-compose docker compose config --quiet
sbx exec handbook-compose docker compose up -d
sbx exec handbook-compose docker compose ps
sbx exec handbook-compose docker compose exec cache redis-cli ping
sbx ports handbook-compose --publish 127.0.0.1:8089:8080

Open http://127.0.0.1:8089/ on the host. The cache has no published host port. The web service does not use the cache; this deliberately small stack teaches service management and port boundaries before introducing application code.

Expected observations

The cache probe should return PONG and the browser should show nginx’s default page. Record the actual result, image digests and container status. If image pulls are denied, stop and inspect the intended registry access rather than changing a global preset.

For cleanup, stop only this teaching project and remove its mapping:

sbx exec handbook-compose docker compose down
sbx ports handbook-compose --unpublish 8089:8080

Review any outputs before removing the named sandbox.

Troubleshooting

Use docker compose ps and bounded service logs to distinguish a crashed process from a missing mapping. A Compose health check is another executed command, not merely metadata.

Current cloud documentation warns that Docker exec, Compose exec and health checks can target the wrong filesystem in cloud sandboxes. This local exercise is not a claim of cloud parity. Check that limitation before moving a workload.

Interview practice

Why does cache:6379 work for a peer service but not necessarily for the host?

The name belongs to the Compose network. The host needs an explicit exposure path, which this lab deliberately does not create for the cache.

Does compose down prove the sandbox was deleted?

No. It manages the Compose project. The sandbox and its private Engine can persist, including images and other stored state.

Completion check

Draw all three port layers, identify the unexposed cache, and show the project stopped without deleting unrelated resources.

Sources and version notes

Checked 6 October 2026; current baseline: sbx v0.46.0. Develop and test locally · Use cloud sandboxes

YOUR NEXT STEP

Make the understanding yours.

Use the completion check above. Mark this chapter when you can explain the mechanism and its limits.

Self-assessed reading progress. This does not certify that a lab ran or a system is secure.