Bash script for QoL improvements managing docker stacks from the CLI
dsctl is a lightweight shell helper to manage multiple Docker Compose stacks located in a single directory ($HOME/services by default). It allows you to start, stop, reload, update, edit, and inspect Docker stacks with a simple command interface.
- Download
dsctl.sh - Make it executable:
chmod +x dsctl.sh- Install
./dsctl.sh installBefore making any changes, the script will show a summary of actions:
- Create the directory
$HOME/.local/binif it doesn’t exist. - Copy
dsctl.shto$HOME/.local/bin/dsctl. - Make the script executable.
- Add a
sourceline to your shell configuration (~/.bashrcor~/.zshrc). - Enable autocompletion for
dsctl. - Check for Docker Compose (
docker composeordocker-compose). - Optionally create the services folder (default:
$HOME/services).
The script prompts:
Proceed with install? [y/N]
- Y → proceed with installation.
- N (or Enter) → cancel safely.
- Ensures
$HOME/.local/binexists for the command. - Creates
$HOME/servicesif it doesn’t exist.
- Copies itself to
$HOME/.local/bin/dsctl. - Sets executable permissions:
chmod +x $HOME/.local/bin/dsctl- Detects your shell (
bashorzsh). - Adds this line to your shell rc file if missing:
source $HOME/.local/bin/dsctl- Makes
dsctland autocomplete available in all new shell sessions.
- Adds autocomplete for
dsctlcommands and services. - Works immediately in the current shell session.
- Detects
docker composeordocker-compose. - If neither is found, the script stops and asks you to install Docker Compose.
After completion, you will see:
Installed to $HOME/.local/bin/dsctl and sourced in ~/.bashrc.
Autocomplete enabled.
- Now
dsctlis fully ready to use.
- Run
dsctlanywhere in your terminal. - Autocomplete will suggest services and actions.
- You can manage services in parallel with color-coded success/failure.
- Persistent alias management is available:
dsctl alias ds # create alias "ds"
dsctl alias off # remove alias
dsctl alias status # check alias status- Run commands for all services or a single service:
dsctl list
dsctl all reload
dsctl romm up
dsctl romm edit- Services directory:
$HOME/services(default). - Compose file name:
compose.yml(default, can override viaCOMPOSE_FILE). - Editor: defaults to
nano(can override viaEDITOR). - Parallel jobs: maximum parallel operations via
MAX_DS_JOBS(default: 4).
dsctl <service|a> <action>| Command | Usage | Explanation |
|---|---|---|
| new | dsctl new | Create a new service folder and compose file, then open it in the editor. |
| del | dsctl del | Delete the service folder and all its contents. |
| up | dsctl up | Start the service in detached mode (docker compose up -d). |
| down | dsctl down | Stop the service (docker compose down). |
| reload | dsctl reload | Restart the service (down + up). |
| update | dsctl update | Pull latest images and restart the service; prune unused images. |
| edit | dsctl edit | Open the compose file in the configured editor. |
| env | dsctl env | Open or create a .env file for the service in the editor. |
| cd | dsctl cd | Change directory to the service folder. |
| ls | dsctl ls | List files and folders under the service folder. |
| Command | Usage | Explanation |
|---|---|---|
| up | dsctl all up | Start all services in parallel. |
| down | dsctl all down | Stop all services in parallel. |
| reload | dsctl all reload | Restart all services in parallel. |
| update | dsctl all update | Pull images and restart all services in parallel. |
| prune | dsctl all prune | Remove unused Docker images after updating all services. |
| Command | Usage | Explanation |
|---|---|---|
| list | dsctl list | Show all service folders and their current status (running, stopped, down, or non-stack). |
| clean | dsctl clean | Delete all folders that do not contain a compose file. Prompts for confirmation. |
| dry-clean | dsctl dry-clean | Show all non-stack folders without deleting them. |
| help | dsctl help | Show usage information. |
| alias | dsctl alias | Create, remove, or check persistent aliases for dsctl (alias <name>, off, status). |
| install | dsctl install | Run interactive installation for dsctl and enable autocompletion. |
| Command | Usage | Explanation |
|---|---|---|
| alias | dsctl alias <name> / off / status | Create, remove, or check persistent aliases for dsctl. |
| install | dsctl install | Run the interactive installation for dsctl and enable autocompletion. Already done during installation. |