Dock is a custom CLI tool designed to streamline the management of Docker Compose environments. With Dock, you can easily start, stop, build, and monitor your Docker Compose services using a single configuration file and straightforward commands.
- Simplifies Docker Compose workflows for multiple environments.
- Configurable through a
.dock
YAML file for custom environments. - Supports commands to start, stop, build, restart, monitor, and clean Docker containers and services.
- Purge all Docker data in a single command (with confirmation).
- Supports building images without using cache (
--no-cache
or-nc
). - Installable via Homebrew or manual setup.
You can install Dock using Homebrew:
-
Add the Dock tap:
brew tap geeth24/dock
-
Install Dock:
brew install dock
After installation, you should be able to run dock
commands from the terminal.
Alternatively, you can download and set up Dock manually:
-
Clone the repository:
git clone https://github.com/geeth24/dock.git cd dock
-
Install dependencies:
pip install -r requirements.txt
-
Make the script executable:
chmod +x dock
-
Move the script to a directory in your PATH (e.g.,
/usr/local/bin/
):sudo mv dock /usr/local/bin/
Now you can use dock
from anywhere in your terminal.
To configure Dock for different environments, create a .dock
file in your project root. This file should define each environment with its corresponding docker-compose
file.
Example .dock
file:
dev: docker-compose-dev.yml
prod: docker-compose-prod.yml
test: docker-compose-test.yml
This allows you to use dock <environment> <command>
for different Docker Compose setups.
Dock uses short aliases for common Docker Compose commands. Here’s a complete list of commands:
Start the specified environment in detached mode.
dock <env> u
Example:
dock dev u # Starts the 'dev' environment in detached mode
Stop the specified environment.
dock <env> d
Example:
dock dev d # Stops the 'dev' environment
Build and start the specified environment.
dock <env> b [options]
Example:
dock dev b # Builds and starts the 'dev' environment
Restart the services in the specified environment.
dock <env> r
Example:
dock dev r # Restarts the 'dev' environment services
Follow logs for the specified environment.
dock <env> logs
Example:
dock dev logs # Follows logs for the 'dev' environment
Display the status of services in the specified environment.
dock <env> status
Example:
dock dev status # Shows status of the 'dev' environment services
Remove stopped containers in the specified environment.
dock <env> rm
Example:
dock dev rm # Removes stopped containers in the 'dev' environment
Stops all currently running Docker containers across all environments.
dock any_env stop_all
Example:
dock dev stop_all # Stops all Docker containers
Warning: The purge
command will delete all Docker containers, images, volumes, and networks.
dock any_env purge
Example:
dock dev purge # Prompts for confirmation before purging all Docker data
Note: This command prompts for confirmation before proceeding.
Dock commands can include the following option:
Use this flag with the b
(build) command to ensure Docker builds images without using cached layers.
Example:
dock dev b --no-cache # Builds 'dev' environment without cache
dock dev b -nc # Alias for the same functionality
Here are some example usages of Dock commands:
-
Start the Development Environment:
dock dev u
-
Stop the Production Environment:
dock prod d
-
Build and Start the Test Environment Without Cache:
dock test b --no-cache
-
Follow Logs in the Development Environment:
dock dev logs
-
Purge All Docker Data:
dock any_env purge
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes and commit (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.