# Docker - Linux Docker Compose Wrapper

**Docker Compose Wrapper (dc)**

A small wrapper around docker compose that automatically loads shared environment files for all stacks.

**Why**

Docker Compose only interpolates ${VARIABLES} from:

- The shell environment, or
- A local .env file, or
- Files passed with --env-file

It does **not** use the env\_file: directive for interpolation.  
This wrapper always passes the shared files so every stack gets consistent variable substitution.

**Shared Files**

/mnt/volume1/docker/stacks/\_shared/.env  
/mnt/volume1/docker/stacks/\_shared/.secret

**Install**

1. Create the wrapper:

<div dir="auto" id="bkmrk-bash"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
sudo tee /usr/local/bin/dc > /dev/null << 'EOF'
#!/bin/bash
exec docker compose \
  --env-file /mnt/volume1/docker/stacks/_shared/.env \
  --env-file /mnt/volume1/docker/stacks/_shared/.secret \
  "$@"
EOF
```

2. Make it executable:

<div dir="auto" id="bkmrk-bash-1"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
sudo chmod +x /usr/local/bin/dc
```

3. Verify:

<div dir="auto" id="bkmrk-bash-2"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
which dc
dc version
```

**Usage**

Use dc exactly like docker compose.  
All subcommands work.

<div dir="auto" id="bkmrk-bash-3"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
dc up -d
dc logs
dc logs -f
dc ps
dc restart <service>
dc down
dc config
```

**Notes**

- Run dc from the directory that contains the docker-compose.yml (same as normal Compose).
- Later --env-file overrides earlier ones if keys collide.
- The wrapper does not change how env\_file: works inside containers — it only handles interpolation for the Compose file itself.
- To see the fully resolved config before starting anything:

<div dir="auto" id="bkmrk-bash-4"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
dc config
```

**Updating**

Edit the script if the shared file paths change:

<div dir="auto" id="bkmrk-bash-5"><div data-testid="code-block"><div><div>Bash <div>  
</div></div><div></div></div></div></div>```
sudo nano /usr/local/bin/dc
```