Docker-Compose
...
Networking
By default Docker-Compose will create a new network for the given compose file. You can change the behavior by defining custom networks in your compose file.
Create and assign custom network
... Example:
1 2 3 4 5 6 7 | |
Use existing networks
If you want to use an existing Docker network for your compose files, you can add the external: true parameter in your compose file
Example:
1 2 3 | |
Volumes
Volumes are data storage objects that Docker containers can use for persistent storage.
Create and map static volume(s)
1 2 3 4 5 6 7 | |
These volumes are stored in /var/lib/docker/volumes.
Create volume that is a CIFS mount to external share
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Environment Variables
Environment variables can be defined in the environment section of a service in a Docker Compose file.
Define environment variables
1 2 3 4 | |
Interpolate environment variables
| Variable | Description |
|---|---|
${ENV_VAR} |
Value of ENV_VAR |
${ENV_VAR:-default} |
Value of ENV_VAR if set and non-empty, otherwise default |
${ENV_VAR-default} |
Value of ENV_VAR if set, otherwise default |
${ENV_VAR:?error} |
Value of ENV_VAR if set and non-empty, otherwise exit with error |
${ENV_VAR?error} |
Value of ENV_VAR if set, otherwise exit with error |
${ENV_VAR:+replacement} |
replacement if ENV_VAR is set and non-empty, otherwise empty |
${ENV_VAR+replacement} |
replacement if ENV_VAR is set, otherwise empty |