docker-compose.override.yml
docker-compose.override.yml
The docker-compose.override.yml is the configuration file where you
can override existing settings from docker-compose.yml or even add
completely new services.
By default, this file does not exist and you must create it. You can
either copy the existing docker-compose.override.yml-example or create
a new one.
How does docker-compose.override.yml work?
When you run docker-compose up, it searches for a file named
docker-compose.yml and reads all configured services, networks,
volumes etc to create your Docker stack. If you also additionally have a
file named docker-compose.override.yml this will be read as well and
used as an override file to complement. It works in the following order:
- All definitions from
docker-compose.ymlwill be used - All definitions that are also defined in
docker-compose.override.ymlwill automatically overwrite the settings fromdocker-compose.yml - All definitions only available in
docker-compose.override.ymlwill be added additionally.
For starting up your Docker Compose stack there are no additional steps or command line arguments required. If both files exist, they will be read automatically.
docker compose extends
Create docker-compose.override.yml
Copy example file
host> cd path/to/devilboxhost> cp docker-compose.override.yml-example docker-compose.override.ymlCreate new file from scratch
- Create an empty file within the Devilbox git directory named
docker-compose.override.yml - Retrieve the currently used version from the existing
docker-compose.ymlfile - Copy this version line to your newly created
docker-compose.override.ymlat the very top
# Create an empty filehost> cd path/to/devilboxhost> touch docker-compose.override.yml
# Retrieve the current versionhost> grep ^version docker-compose.ymlversion: '2.1'
# Add this version line to docker-compose.override.ymlhost> echo "version: '2.1'" > docker-compose.override.ymlLet’s see again how this file should look like now:
version: '2.1'[!NOTE] The documentation might be outdated and the version number might already be higher. Rely on the output of the
grepcommand.
Further reading
To dive deeper into this topic and see how to actually add new services or overwrite existing services follow the below listed links:
* add-your-own-docker-image * overwrite-existing-docker-image