44 lines
2.1 KiB
Markdown
44 lines
2.1 KiB
Markdown
---
|
|
tags:
|
|
- Scirpts
|
|
- Desktop
|
|
---
|
|
# 🐳 Docker Engine Installation Guide (`install-docker.sh`)
|
|
|
|
This script automates and guides the installation of Docker CLI, Docker Engine, and necessary dependencies on a Linux host system. **WARNING: Running this script requires elevated privileges (`sudo`).** Always run from a secure, non-production machine initially.
|
|
|
|
## 🗺️ Prerequisites
|
|
Before running any provisioning script, ensure the following are in place:
|
|
* A functional `curl` client is installed.
|
|
* The user executing the command has appropriate permissions (system administrator level rights).
|
|
|
|
## Execution Protocol
|
|
|
|
The process follows three critical, distinct steps to ensure the entire stack is correctly configured and operational:
|
|
|
|
### Step 1: Download the Official Installation Script
|
|
Use `curl` to fetch the latest official installation manifest from Docker.
|
|
|
|
```bash
|
|
# Execute this command in your shell terminal
|
|
curl -fsSL https://get.docker.com -o install-docker.sh
|
|
```
|
|
|
|
### Step 2: Run the Installation Script
|
|
Execute the downloaded script with elevated permissions. This step pulls and configures all necessary binaries and services.
|
|
|
|
```bash
|
|
sudo sh install-docker.sh
|
|
```
|
|
*Wait for the output to confirm successful installation across all components.*
|
|
|
|
### Step 3: Configure User Permissions (Non-negotiable)
|
|
Docker commands require administrative access by default. To run Docker without prefixing every command with `sudo`, you must add your current user (`$USER`) to the `docker` group.
|
|
|
|
```bash
|
|
sudo usermod -aG docker $USER
|
|
```
|
|
***Note: You must log out and log back in for this group change to take effect.***
|
|
|
|
> [!NOTE] Modernized Workflow
|
|
For automated, production deployment (CI/CD), **avoid standalone shell scripts like this.** Best practice dictates using infrastructure-as-code tools such as **Ansible** or **Terraform**. These platforms manage dependencies and state much better than a sequential script execution, allowing you to define the *desired final state* of Docker rather than merely listing steps to achieve it. Always prefer declarative configuration over imperative scripts where possible. |