Home Explore Blog CI



docker

3rd chunk of `content/manuals/compose/intro/compose-application-model.md`
46d8ae8aa47d4b76c74c7988cc52f2713a8e4b9f192be4b400000001000007f4


The example application is composed of the following parts:

- 2 services, backed by Docker images: `webapp` and `database`
- 1 secret (HTTPS certificate), injected into the frontend
- 1 configuration (HTTP), injected into the frontend
- 1 persistent volume, attached to the backend
- 2 networks

```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:

```text
$ docker compose ps

NAME                IMAGE                COMMAND                  SERVICE             CREATED             STATUS              PORTS
example-frontend-1  example/webapp       "nginx -g 'daemon of…"   frontend            2 minutes ago       Up 2 minutes        0.0.0.0:443->8043/tcp
example-backend-1   example/database     "docker-entrypoint.s…"   backend             2 minutes ago       Up 2 minutes
```

## What's next 

- [Quickstart](/manuals/compose/gettingstarted.md)
- [Explore some sample applications](/manuals/compose/support-and-feedback/samples-for-compose.md)
- [Familiarize yourself with the Compose Specification](/reference/compose-file/_index.md)

Title: Example Docker Compose Application: Frontend and Backend Services
Summary
This section presents an example Docker Compose application composed of a frontend webapp and a backend database service. The example illustrates the use of Docker images, secrets, configurations, persistent volumes, and networks within a `compose.yaml` file. The frontend exposes port 443, while the backend uses a persistent volume for data storage. The `docker compose up` command starts the services, and `docker compose ps` provides the status of running containers. The document concludes with pointers to further resources, including a quickstart guide and sample applications.