Skillversitas

Installing Docker

This tutorial explains how to install Docker on various operating systems.

System Requirements

Windows

  • Windows 10/11 64-bit with WSL 2
  • Hyper-V enabled
  • Minimum 4GB RAM

macOS

  • macOS 10.15 (Catalina) or newer
  • Minimum 4GB RAM

Linux (Ubuntu/Debian)

# Update package index
sudo apt-get update

# Install prerequisites
sudo apt-get install -y \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

# Add Docker's official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
    sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# Set up repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

Verifying the Installation

# Check the Docker version
docker --version

# Check the Docker daemon status
sudo systemctl status docker

# Run a test container
sudo docker run hello-world

Post-Install Configuration

Adding a User to the Docker Group

# Add the user to the docker group
sudo usermod -aG docker $USER

# Activate the group (or log out/log in)
newgrp docker

# Verify without sudo
docker run hello-world

Auto-start Docker

# Enable Docker at boot
sudo systemctl enable docker

Docker Desktop Installation

Windows/macOS

  1. Download Docker Desktop from https://www.docker.com/products/docker-desktop
  2. Run the installer
  3. Follow the installation wizard
  4. Restart your computer if required

Use Case: Setting Up a Development Team

Case: 5 developers need to set up Docker on their respective computers.

Solution:

# Installation script for Ubuntu
#!/bin/bash
echo "=== Docker Installation for the App Team ==="
sudo apt-get update
sudo apt-get install -y docker.io docker-compose
sudo usermod -aG docker $USER
echo "Docker is installed! Log out and log back in."

Troubleshooting

Error: "permission denied"

# Make sure the user is in the docker group
groups $USER
# If not, add them:
sudo usermod -aG docker $USER

Error: "Cannot connect to Docker daemon"

# Start the Docker service
sudo systemctl start docker
# or restart it
sudo systemctl restart docker

Everyday Use Case

Case: A new developer on the app backend team needs to install Docker to run the application.

Solution: Provide a tested automatic installation script. The team can run a single command for a complete setup.

Conclusion

Installing Docker is relatively easy on all platforms. Make sure to verify the installation and apply the post-install configuration so that Docker runs without needing sudo.