A dead-simple, quality-of-life CLI booster for quick Docker (Compose) container access.
Save time by running commands in containers dynamically resolved from your local directory configuration.
- Context-Aware — Remembers configuration per-directory via a local
.dexfile. - Docker Compose Mode — Resolves container IDs dynamically from a service name (e.g.
app) and compose file, avoiding stale IDs. - Direct Container Mode — Executes directly against a fixed container name if Docker Compose isn't used.
- Compose Shortcuts — Built-in support for
--up,--down,--restart, and--recreatedirectly inside your target project. - Interactive Shells — Running
dexwithout commands automatically spins up an interactive shell inside the container (defaults tosh, configurable in.dex).
dex -a, --assign [container_name] Assign a single container name
dex -a, --assign [compose_file] [service_name] Assign a service in a docker-compose file
dex -c, --clear Clear the local dex assignment
dex --up [params] Run docker compose up (compose mode only)
dex --down [params] Run docker compose down (compose mode only)
dex --restart [params] Restart the assigned container/service
dex --recreate [params] Recreate the assigned Compose service with current env
dex [COMMANDS] Run commands as host user by default
dex Start an interactive shell in the assigned container
To assign a Docker Compose service in the current directory:
dex -a docker-compose.dev.yml app
To assign a single running container by it's name:
dex -a cool-container-7
Execute any command inside the container:
dex php artisan migrate
Commands run as your host uid:gid by default, so files created in bind mounts
belong to you. Override this per command when needed:
DEX_USER=0:0 dex php artisan ...
Run dex with no arguments to open an interactive terminal:
dex
Manage your Compose stack from the assigned directory:
dex --up -d dex --down --remove-orphans dex --restart dex --recreate
--restart keeps the container's existing environment.
Use --recreate after changing Compose or .env values: it runs docker compose up -d --no-build --no-deps --force-recreate for the assigned service.
Remove the local directory configuration:
dex -c
# or
dex --clearThe configuration is saved in the current directory inside a .dex file:
MODE="compose" COMPOSE_FILE="docker-compose.dev.yml" SERVICE_NAME="app" SHELL="sh"
MODE="container" CONTAINER_NAME="cool-container-7" SHELL="sh"
curl -fsSL https://raw.githubusercontent.com/madLinux7/dex/main/install.sh | shThis installs the latest published GitHub Release to ~/.local/bin/dex. To
choose another directory, pass INSTALL_DIR to the installer:
curl -fsSL https://raw.githubusercontent.com/madLinux7/dex/main/install.sh | INSTALL_DIR="$HOME/bin" sh
Clone the repository and copy the script to your local bin directory:
git clone https://github.com/madLinux7/dex.git cd dex chmod +x dex cp dex ~/.local/bin/dex