install-docker.sh — Docker installer script
Purpose
- Installs Docker Engine, CLI, containerd and Compose plugin across common Linux distributions (Ubuntu/Debian, CentOS/RHEL, Fedora, Alpine, Arch).
Requirements
- A Linux system with one of the supported distributions.
sudoprivileges for the user running the script.- Internet access to download packages from Docker repositories.
Usage
- Make the script executable (if not already):
chmod +x install-docker.sh
- Run the script as your normal user (you will be prompted for sudo):
./install-docker.sh
The script detects your OS via /etc/os-release and runs the appropriate package commands.
Post-install steps
- The script enables and starts the Docker service via
systemctl. - It also adds the current user to the
dockergroup. You may need to log out and log back in (or runnewgrp docker) to use Docker withoutsudo.
Notes & Troubleshooting
- Unsupported OS: the script exits with an error if the distribution is not recognized.
- On systems without
systemd(or wheresystemctlis unavailable), service start/enable will fail—start Docker manually as appropriate for your init system. - If package repository GPG fetch or keyring operations fail, verify network access and that
curl/gnupgare present. - The script assumes typical package managers:
apt,yum,dnf,apk, orpacman.
Example
# Run installer (prompts for sudo)
./install-docker.sh
# Verify Docker
docker --version
sudo systemctl status docker
Security
- The script adds official Docker package repositories and installs upstream packages. Review the commands if you have custom security requirements.
Contributing / Changes
- To adapt the script for additional distributions or custom mirrors, add/modify the
casebranches that handle installation for eachOS.
License
- No license included. If you want this README or script under a specific license, add a LICENSE file.
Description
Languages
Shell
100%