How does Docker Compose work with multiple .yml files?
Experience Level: Senior
Tags: Docker Compose
Answer
You can combine a configuration from multiple files like this:
docker compose -f file1.yml -f file2.yml -f file3.yml up
When you do this, Docker Compose processes files from the first one to the last one, in the order as they are defined. If the file defined later contains the same property as a file defined earlier, the property values are overridden.
Related Docker Compose job interview questions
How do tell Docker Compose to use custom .env2 file without passing it in command-line argument?
Docker Compose SeniorHow do you define a default value in Docker Compose interpolation?
Docker Compose SeniorHow do you pull all images associated with services defined in your docker-compose.yml file?
Docker Compose SeniorUsing Docker Compose, how do you define that a service should be restarted after a failure?
Docker Compose SeniorUsing Docker Compose, how do you define that one service is dependent on another service?
Docker Compose Senior