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
.dockYAML 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-cacheor-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.ymlThis 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> uExample:
dock dev u # Starts the 'dev' environment in detached modeStop the specified environment.
dock <env> dExample:
dock dev d # Stops the 'dev' environmentBuild and start the specified environment.
dock <env> b [options]Example:
dock dev b # Builds and starts the 'dev' environmentRestart the services in the specified environment.
dock <env> rExample:
dock dev r # Restarts the 'dev' environment servicesFollow logs for the specified environment.
dock <env> logsExample:
dock dev logs # Follows logs for the 'dev' environmentDisplay the status of services in the specified environment.
dock <env> statusExample:
dock dev status # Shows status of the 'dev' environment servicesRemove stopped containers in the specified environment.
dock <env> rmExample:
dock dev rm # Removes stopped containers in the 'dev' environmentStops all currently running Docker containers across all environments.
dock any_env stop_allExample:
dock dev stop_all # Stops all Docker containersWarning: The purge command will delete all Docker containers, images, volumes, and networks.
dock any_env purgeExample:
dock dev purge # Prompts for confirmation before purging all Docker dataNote: 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 functionalityHere 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.