A CLI tool for discovering Docker Compose files and their services across multiple directories.
Select a Compose file and service interactively, then execute a custom command on the service.
- Automatically searches for Docker Compose files (
docker-compose.yml
,compose.yml
, etc.) in predefined paths. - Interactive terminal-based UI for selecting Compose files and services.
- Executes a configurable shell command on the selected service.
- Download the latest release binary from the releases page.
wget https://github.com/doppelar0n/docker-compose-exec/releases/latest/download/docker-compose-exec-amd64
- Copy the binary to
/usr/local/bin
:sudo mv docker-compose-exec-amd64 /usr/local/bin/docker-compose-exec
- Make the binary executable:
sudo chmod +x /usr/local/bin/docker-compose-exec
Just run:
docker-compose-exec
This launch the tool with default paths and interactive UI.
You can configure the following environment variables:
- CONTAINER_BASE_PATH
Specify paths to search for Docker Compose files (colon-separated). Example:
Default paths include
export CONTAINER_BASE_PATH="/path/to/containers:/another/path"
/var/container
and/srv/container
. - CONTAINER_EXEC_COMMAND
Customize the execution command. Example:
export CONTAINER_EXEC_COMMAND="docker compose -f %COMPOSE exec --user root %SERVICE /bin/bash"
%COMPOSE
will be replaced with the path to the selected Compose file.%SERVICE
will be replaced with the selected service.
Imagine you have the following directory structure:
/var/container
├── project1/
│ └── docker-compose.yml
├── project2/
│ └── compose.yml
/srv/container
└── project3/
└── docker-compose.yaml
Running docker-compose-exec
will:
- Discover these Compose files.
- Allow you to select a file (e.g., project1/docker-compose.yml).
- List available services from the selected file.
- Execute the configured command (e.g., docker exec) on the chosen service.
- Specify custom search paths for Compose files.
CONTAINER_BASE_PATH="/var/mycontainers:/srv/containers" docker-compose-exec
- Use a custom execution command.
CONTAINER_EXEC_COMMAND="docker compose -f %COMPOSE exec %SERVICE /bin/bash" docker-compose-exec
- This is like dry run. (--dry-run)
CONTAINER_EXEC_COMMAND="echo %COMPOSE %SERVICE" docker-compose-exec
Contributions are welcome! Please open an issue or submit a pull request with any enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for more information.