Docker - Linux Docker Compose Wrapper
October 12, 2026

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:
Bash

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
  1. Make it executable:
Bash

sudo chmod +x /usr/local/bin/dc
  1. Verify:
Bash

which dc dc version

Usage

Use dc exactly like docker compose.
All subcommands work.

Bash

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:
Bash

dc config

Updating

Edit the script if the shared file paths change:

Bash

sudo nano /usr/local/bin/dc

Leave a Reply

Your email address will not be published. Required fields are marked *

Slingbuilt