TOPIC 08/1916 MINNOT STARTED

Docker Compose: service names, ports, a named volume and exec

Start an app and its data store together, see why services find each other by name, keep data across a restart, and run a command inside one service.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a market street with a gate and a store room. The stalls call each other by the name on the sign. Visitors from the road use the gate number, not the stall's private door. A store room behind the street keeps stock when the stalls are packed away at night.

The street is the . The sign is the service name. The store room is a named volume. Stepping into a stall to look at a box is exec.

Tom, a tester at Daily List, a to-do list app, needs the app and its data store up together.

What it is: Docker Compose starts several containers from one file, usually compose.yaml. A Compose network lets services find each other by name, and a keeps data after docker compose down. To is to run a command inside a service that is already up. One docker run is the neighbour, and it starts a single container. Compose starts the whole set and wires the names.

Why it matters: A Daily List test needs the app and a data store together. It fails if Tom starts only one of them. It also fails if the app looks for a laptop address that changes. Compose gives a stable service name, a host port for the browser and a volume so a restart does not wipe the rows. Exec lets him look inside when a service is up but the page is wrong.

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB A market street with stalls, a street gate and a store room.

  1. Street
  2. Gate
  3. Storeroom
Market street

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The street the stalls shareThe Compose network
The name on a stall signThe service name
The gate to the road outsideThe host port
The store room behind the streetThe named volume

WHERE THIS PICTURE STOPS

  • A sign is painted once, but a service name is set in the file.
  • A gate faces the road, but services reach each other inside the street.
  • A store room can be cleared by hand, and down with the volumes option does that.

HOOK

Street, gate, store room.

TELL A FRIEND

Stalls on a street with a gate and a store room.

OFTEN MIXED UP WITH Docker part 2: write a Dockerfile and build your own test image. That topic builds one image from a Dockerfile. This one starts several services together and keeps their data.

PRACTISE AND KEEP

Sources for this topic — 5 sources
  1. Market practice

    Networking in Compose (Docker documentation) ↗ — Docker · Docker docs on networking in Compose: Compose creates a default network named after the project and attaches every service to it, a service name works as a host name on that network, and container addresses can change so names are the safe choice

    The Docker page on networking in Compose: Compose creates a default network named after the project, attaches every service to it, and a service name works as a host name on that network, so use names and not addresses. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  2. Market practice

    Docker Compose Quickstart (Docker documentation) ↗ — Docker · Docker Compose quickstart: a compose.yaml with a web service and a cache store service, host port 8000 maps to container port 5000, and a named volume registered under the top-level volumes key survives docker compose down and up unless the v option is added

    The Docker quickstart: a compose.yaml with a web service and a cache store service, and host port 8000 mapped to container port 5000. A top-level volumes key lets a named volume survive docker compose down and up unless you add the v option. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    docker compose exec and docker compose down (Docker reference) ↗ — Docker · Docker reference: docker compose exec runs a command in an already-running container in the form exec, options, service, command, and docker compose down removes containers and networks and removes volumes only when the v option is given

    The Docker reference pages: docker compose exec runs a command in an already-running service container with the form exec, options, service, command; docker compose down stops and removes containers and networks, and removes volumes only with the v option. · Checked 2026-10-31

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Control startup order in Compose ↗ — Docker · Running is not ready; healthcheck and depends_on service_healthy.

    Current startup-order guide: dependency ordering differs from readiness; healthcheck and service_healthy coordinate database example. · Checked 2026-11-06

    Publisher primary source opened and relevant sections read on 6 November 2026 for the Agile/DevOps domain analysis. Original explanations are used; no extensive source text is copied. Also read for the CI/Containers analysis; live documentation does not establish the version installed in a learner environment.

  5. Market practice

    Docker volumes ↗ — Docker · Mounted-path persistence beyond container removal; explicit volume deletion.

    Mounted-path persistence beyond container removal; explicit volume deletion. · Checked 2026-11-06

    Actual primary documentation body read during the complete V30 domain analysis before implementation. Live documentation access-dated; no claim this version is installed in the learner environment. No artwork copied by this content change.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.