Combining multiple Compose files into one
We have created various environments by combining compose files. This will assist the development process; however, it will make it more complex. Compose gives us the option to combine the various compose files used for the various use cases into one.
Using config
Note that config
is a Docker compose command that will merge the files specified.
For example, we can try it when we want to run the location service as standalone:
docker compose -f base-compose.yaml -f location-service/docker-compose.yaml config
The result will be the unified JSON:
name: chapter7 services: location-service: build: context: /path/to/git/A-Developer-s-Essential-Guide-to-Docker-Compose/Chapter7/location-service dockerfile: Dockerfile depends_on: redis: ...