Skip to content

Commit f82ba3a

Browse files
add docker compose environment interpolation
1 parent c97316a commit f82ba3a

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

docker/docker-compose.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Docker-Compose
2+
23
...
34

45
## Networking
6+
57
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.
8+
69
### Create and assign custom network
10+
711
...
812
*Example:*
13+
914
```yaml
1015
networks:
1116
custom-network:
@@ -15,18 +20,24 @@ services:
1520
networks:
1621
- custom-network
1722
```
23+
1824
### Use existing networks
25+
1926
If you want to use an existing Docker network for your compose files, you can add the `external: true` parameter in your compose file
2027
*Example:*
28+
2129
```yaml
2230
networks:
2331
existing-network:
2432
external: true
2533
```
2634

2735
## Volumes
28-
Volumes are data storage objects that Docker containers can use for persistent storage.
36+
37+
Volumes are data storage objects that Docker containers can use for persistent storage.
38+
2939
### Create and map static volume(s)
40+
3041
```yaml
3142
volumes:
3243
my-volume:
@@ -36,8 +47,11 @@ services:
3647
volumes:
3748
- my-volume:/path-in-container
3849
```
50+
3951
These volumes are stored in `/var/lib/docker/volumes`.
52+
4053
### Create volume that is a CIFS mount to external share
54+
4155
```yaml
4256
# Variables that will need to be changed:
4357
# <PUID> - User id for folder/file permissions
@@ -72,3 +86,28 @@ volumes:
7286
device: //<REMOTE_IP>/<PATH_TO_LIBRARY>
7387
o: "username=<USERNAME>,password=<PASSWORD>,vers=3.0,uid=<PUID>,gid=<PGID>"
7488
```
89+
90+
## Environment Variables
91+
92+
Environment variables can be defined in the `environment` section of a service in a Docker Compose file.
93+
94+
### Define environment variables
95+
96+
```yaml
97+
services:
98+
app:
99+
environment:
100+
- ENV_VAR=value
101+
```
102+
103+
### Interpolate environment variables
104+
105+
| Variable | Description |
106+
| --- | --- |
107+
| `${ENV_VAR}` | Value of `ENV_VAR` |
108+
| `${ENV_VAR:-default}` | Value of `ENV_VAR` if set and non-empty, otherwise `default`|
109+
| `${ENV_VAR-default}` | Value of `ENV_VAR` if set, otherwise `default`|
110+
| `${ENV_VAR:?error}` | Value of `ENV_VAR` if set and non-empty, otherwise exit with `error` |
111+
| `${ENV_VAR?error}` | Value of `ENV_VAR` if set, otherwise exit with `error` |
112+
| `${ENV_VAR:+replacement}` | `replacement` if `ENV_VAR` is set and non-empty, otherwise empty |
113+
| `${ENV_VAR+replacement}` | `replacement` if `ENV_VAR` is set, otherwise empty |

docker/docker-networking.md

Whitespace-only changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy