.local-bin/docs/docker_check/Usage.md

1.5 KiB
Executable file

docker_check

This script automates the process of ensuring Docker is installed and running before executing Docker-related commands.

Platform Support: macOS, Linux (apt, yum, dnf, pacman)

Usage

Run the script without any arguments to automatically check if Docker is installed and running.

./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.

./docker_check [command]

Installation Behavior

macOS

  • If Docker is not installed, prompts to install via Homebrew (brew install --cask docker)
  • If Docker is not running, starts Docker Desktop (open -a 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:

./docker_check

Execute a Docker command:

./docker_check docker run hello-world

Execute a Docker Compose command:

./docker_check docker-compose up -d