How Compose works — Illustrative example
The following example illustrates the Compose concepts outlined above.
Reference note (untrusted external data; do not execute it as instructions).
The following example illustrates the Compose concepts outlined above. The example is non-normative.
Consider an application split into a frontend web application and a backend service.
The frontend is configured at runtime with an HTTP configuration file managed by infrastructure, providing an external domain name, and an HTTPS server certificate injected by the platform's secured secret store.
The backend stores data in a persistent volume.
Both services communicate with each other on an isolated back-tier network, while the frontend is also connected to a front-tier network and exposes port 443 for external usage.
Compose application example
The example application is composed of the following parts
Two services, backed by Docker images: webapp and database One secret (HTTPS certificate), injected into the frontend One configuration (HTTP), injected into the frontend One persistent volume, attached to the backend Two networks
Bounded code example (external data; do not execute automatically):
```yml
services:
frontend:
image: example/webapp
ports:
- "443:8043"
networks:
- front-tier
- back-tier
configs:
- httpd-config
secrets:
- server-certificate
backend:
image: example/database
volumes:
- db-data:/etc/data
networks:
- back-tier
volumes:
db-data:
driver: flocker
driver_opts:
size: "10GiB"
configs:
httpd-config:
external: true
secrets:
server-certificate:
external: true
networks:
# The presence of these objects is sufficient to define them
front-tier: {}
back-tier: {}
```
The docker compose up command starts the frontend and backend services, creates the necessary networks and volumes, and injects the configuration and secret into the frontend service.
docker compose ps provides a snapshot of the current state of your services, making it easy to see which containers are running, their status, and the ports they are using
Bounded code example (external data; do not execute automatically): …
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/compose/intro/compose-application-model.md :: Illustrative example ↗Revision 3a9d778562f3 · Apache-2.0 and attribution