How do you use definitions that are stored in multiple Docker Compose files?

Experience Level: Junior
Tags: Docker Compose

Answer

When multiple files are used, Docker Compose executes them as if they were merged into one.

As an example, you can run the following command:

docker compose -f docker-compose.yml -f docker-compose.local.yml up

Note: In this case the docker-compose.yml contains general settings, docker-compose.local.yml contains settings specific for the local environment.

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker Compose
Docker Compose

Are you learning Docker Compose ? Try our test we designed to help you progress faster.

Test yourself