.local-bin/docs/docker_check/Usage.md
2026-02-09 13:55:37 -05:00

89 lines
2.3 KiB
Markdown
Executable file

## [docker_check](../../scripts/docker_check)
This script automates the process of ensuring Docker is installed and running before executing Docker-related commands.
**Platform Support:** macOS (Colima, Docker Desktop), Linux (apt, yum, dnf, pacman)
## Usage
Run the script without any arguments to automatically check if Docker is installed and running.
```bash
./docker_check
```
You can also specify a command as an argument to execute Docker-related commands. If the provided command is docker-compose, the script ensures Docker is running before executing `docker-compose`.
```bash
./docker_check [command]
```
## Docker Runtime on macOS
On macOS, the script automatically detects and uses the available Docker runtime:
1. **Colima** (preferred) - Lightweight container runtime using Lima
2. **Docker Desktop** - Official Docker application
If both are installed, Colima is preferred. The script checks the runtime status and starts it if needed.
## Installation Behavior
### macOS
**If Colima is installed:**
- Checks if Colima is running (`colima status`)
- Starts Colima if not running (`colima start`)
**If Docker Desktop is installed:**
- If Docker is not running, starts Docker Desktop (`open -a Docker`)
**If neither is installed:**
- Prompts to choose between:
1. Install Colima (lightweight, recommended) - `brew install colima`
2. Install Docker Desktop (official) - `brew install --cask docker`
### Linux
- Detects package manager (apt, yum, dnf, or pacman)
- If Docker is not installed, prompts to install using the detected package manager
- Installs both `docker.io` (or `docker`) and `docker-compose`
- Enables and starts the Docker service (`systemctl enable --now docker`)
- Adds the current user to the `docker` group (requires logout/login)
- If Docker is not running, starts it via `systemctl start docker`
## Example Usage
Automatically check if Docker is installed and running:
```bash
./docker_check
```
Execute a Docker command:
```bash
./docker_check docker run hello-world
```
Execute a Docker Compose command:
```bash
./docker_check docker-compose up -d
```
## Installing Colima (macOS)
To install Colima manually:
```bash
brew install colima
```
Then start it:
```bash
colima start
```
Colima provides a Docker-compatible CLI without the overhead of Docker Desktop.