Skip to content

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.

License

Notifications You must be signed in to change notification settings

doppelar0n/docker-compose-exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-compose-exec

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.

Features

  • 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.

Installation

  1. Download the latest release binary from the releases page.
    wget https://github.com/doppelar0n/docker-compose-exec/releases/latest/download/docker-compose-exec-amd64
  2. Copy the binary to /usr/local/bin:
    sudo mv docker-compose-exec-amd64 /usr/local/bin/docker-compose-exec
  3. Make the binary executable:
    sudo chmod +x /usr/local/bin/docker-compose-exec

Usage

Just run:

docker-compose-exec

This launch the tool with default paths and interactive UI.

Optional Environment Variables

You can configure the following environment variables:

  • CONTAINER_BASE_PATH Specify paths to search for Docker Compose files (colon-separated). Example:
    export CONTAINER_BASE_PATH="/path/to/containers:/another/path"
    Default paths include /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.

Example

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.

more Examples:

  • 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

Contributing

Contributions are welcome! Please open an issue or submit a pull request with any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages