mirror of
https://github.com/acedanger/shell.git
synced 2026-03-24 20:11:49 -07:00
feat: Implement Docker Manager CLI for managing Docker containers
This commit is contained in:
95
docker-manager/README.md
Normal file
95
docker-manager/README.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# Docker Manager
|
||||
|
||||
A Python command-line application to manage Docker containers defined in subdirectories of `~/docker/`.
|
||||
|
||||
## Features
|
||||
|
||||
- **List**: View currently running containers across all your projects.
|
||||
- **Stop**: Stop containers for a specific project or all projects.
|
||||
- **Update**: Pull the latest images and recreate containers (equivalent to `docker compose pull && docker compose up -d`).
|
||||
- **Restart**: Restart containers for a specific project or all projects.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3
|
||||
- Docker and Docker Compose (plugin) installed.
|
||||
- A `~/docker/` directory containing subdirectories for each of your projects.
|
||||
- Each project subdirectory must contain a `docker-compose.yml` or `compose.yml` file.
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Ensure the script is executable:**
|
||||
```bash
|
||||
chmod +x ~/shell/docker-manager/docker-manager.py
|
||||
```
|
||||
|
||||
2. **Make it accessible from anywhere:**
|
||||
You can create a symbolic link to a directory in your `$PATH` (e.g., `~/.local/bin` or `/usr/local/bin`), or add an alias.
|
||||
|
||||
**Option A: Symbolic Link (Recommended)**
|
||||
```bash
|
||||
mkdir -p ~/.local/bin
|
||||
ln -s ~/shell/docker-manager/docker-manager.py ~/.local/bin/dm
|
||||
```
|
||||
*Note: Ensure `~/.local/bin` is in your `$PATH`.*
|
||||
|
||||
**Option B: Alias**
|
||||
Add the following to your `~/.zshrc` or `~/.bashrc`:
|
||||
```bash
|
||||
alias dm='~/shell/docker-manager/docker-manager.py'
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Run the application using the command name you set up (e.g., `dm`).
|
||||
|
||||
### List Running Containers
|
||||
```bash
|
||||
dm list
|
||||
```
|
||||
|
||||
### Stop Containers
|
||||
Stop a specific project:
|
||||
```bash
|
||||
dm stop project_name
|
||||
```
|
||||
Stop all projects:
|
||||
```bash
|
||||
dm stop --all
|
||||
```
|
||||
|
||||
### Update Containers
|
||||
Pull latest images and recreate containers for a specific project:
|
||||
```bash
|
||||
dm update project_name
|
||||
```
|
||||
Update all projects:
|
||||
```bash
|
||||
dm update --all
|
||||
```
|
||||
|
||||
### Restart Containers
|
||||
Restart a specific project:
|
||||
```bash
|
||||
dm restart project_name
|
||||
```
|
||||
Restart all projects:
|
||||
```bash
|
||||
dm restart --all
|
||||
```
|
||||
|
||||
## Directory Structure Example
|
||||
|
||||
The tool expects a structure like this:
|
||||
|
||||
```
|
||||
~/docker/
|
||||
├── media-server/
|
||||
│ └── docker-compose.yml
|
||||
├── web-app/
|
||||
│ └── compose.yml
|
||||
└── database/
|
||||
└── docker-compose.yml
|
||||
```
|
||||
|
||||
In this example, the project names are `media-server`, `web-app`, and `database`.
|
||||
Reference in New Issue
Block a user