A docker-compose.yml file is a YAML configuration file for managing a multi-container application from one place. It declares services and their runtime-facing settings, so related components such as an API, database, proxy, dashboard, or test server can be built and started together rather than managed separately. section 3.2 section 4.4.2
Start small: define one service, point its build configuration at the service folder and Dockerfile, and map a host port to the container port. Run docker-compose build and docker-compose up, then verify the service through its browser endpoint. Add services incrementally once the first container works. section 3.2 section 4.4.2
A service definition can coordinate several practical concerns:
- Build settings identify the build context and Dockerfile for a service image. section 4.4.2
- Port mappings expose a container service through a chosen host port; a collision can require stopping the conflicting process or changing the mapping. section 3.2.1
- Volumes map local directories into a container, allowing WireMock mappings and files to change without rebuilding the image. section 6.5.1
- Build arguments can pass configuration into an image build, such as a browser-visible API base URL. section 6.8
WireMock service with editable mappings
A WireMock service builds from a dedicated wiremock Dockerfile, maps local __files and mappings directories into the container, and exposes host port 8081 to container port 8080. This separates image building from runtime configuration and lets local stub definitions be updated without rebuilding. section 6.5.1
Use container names rather than localhost when one container connects to another. localhost can point at the current container rather than the database container. Keep database credentials aligned between the Compose configuration and application code when diagnosing authentication failures. section 3.3.2
Listing 6.19 Updates to docker-compose.yml
wiremock:
build:
context: ./wiremock
dockerfile: Dockerfile
volumes: #1
- ./wiremock/__files:/home/wiremock/__files #1
- ./wiremock/mappings:/home/wiremock/mappings #1
ports:
- 8081:8080
This service definition shows a build target, two local-to-container volume mappings, and a port mapping in one compact configuration. section 6.5.1



