A mise plugin that automatically loads environment variables from your Docker Compose configuration into your shell environment.
This plugin resolves your Docker Compose configuration and extracts environment variables defined in your services, making them available in your local development environment. This is useful when you want to match the environment variables used in your containerized services without manually duplicating them.
Add this plugin to your mise configuration:
[plugins]
env-docker-compose = "https://github.com/bo5o/mise-env-docker-compose"
[env]
_.source = "env-docker-compose"The plugin supports several configuration options to control which environment variables are loaded:
Load all environment variables from all services:
[env]
_.env-docker-compose = {}Load environment variables only from specific services:
[env]
_.env-docker-compose = { services = ["web", "api"] }Load only specific environment variable names:
[env]
_.env-docker-compose = { variables = ["DATABASE_URL", "REDIS_URL"] }Replace service references with localhost ports (useful for connecting to containerized services from your host):
[env]
_.env-docker-compose = { replace_hosts = true }When replace_hosts is enabled, environment variable values like postgres:5432 will
be replaced with localhost:5433 (using the published port from your Docker Compose
configuration).
- The plugin runs
docker compose config --format jsonto get the parsed configuration - It extracts environment variables from the
environmentsection of each service - It optionally filters by service names and variable names
- If
replace_hostsis enabled, it replacesservice:portreferences withlocalhost:published_port - The resulting environment variables are made available in your shell
Given a docker-compose.yml:
---
services:
web:
image: myapp
environment:
DATABASE_URL: postgres:5432
API_KEY: secret123
ports:
- "3000:3000"
postgres:
image: postgres:15
environment:
POSTGRES_PASSWORD: password
ports:
- "5433:5432"With this configuration:
[env]
_.env-docker-compose = { services = ["web"], replace_hosts = true }Your shell environment will have:
DATABASE_URL=localhost:5433(replacedpostgres:5432withlocalhost:5433)API_KEY=secret123
- mise installed
- Docker and Docker Compose installed
- Valid Docker Compose configuation in your project