Skip to main content

1. Prerequisites

Before starting, uninstall any old versions of Docker (like docker, docker.io, or docker-engine) to avoid conflicts:

2. Installation on Ubuntu / Debian

Ubuntu is the most popular platform for Docker. Here is how to set it up:

Step 1: Update and Install Dependencies

Step 2: Add Docker’s Official GPG Key

This ensures the software you’re downloading is authentic.

Step 3: Set up the Repository

Step 4: Install Docker Engine

3. Installation on CentOS / RHEL

For Red Hat-based systems, use the yum-utils package.
  1. Install yum-utils: sudo yum install -y yum-utils
  2. Add Repo: sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  3. Install: sudo yum install docker-ce docker-ce-cli containerd.io
  4. Start Docker: sudo systemctl start docker

4. Post-Installation Steps (Important)

By default, you need sudo to run Docker commands. To run Docker as a non-root user, add your user to the docker group:
  1. Create the group: sudo groupadd docker (usually already exists).
  2. Add your user: sudo usermod -aG docker $USER
  3. Apply changes: Log out and log back in, or run newgrp docker.

Verify the Installation

Run the “hello-world” image to make sure everything is working: