Table of Contents
Docker Installation
Install Docker on Ubuntu or Debian for containerized applications.
Docker provides a platform for developing, shipping, and running applications in containers.
Overview
Docker installation on Ubuntu/Debian can be done through the distribution's repository or Docker's official repository. The official repository provides the latest version.
Option 1: Using Distro Repository (Quickest)
```bash sudo apt update sudo apt install -y docker.io ca-certificates curl sudo systemctl enable –now docker ```
This method is quick but may not have the latest Docker version.
Option 2: Using Docker Official Repository (Latest)
```bash sudo apt update sudo apt install -y ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo “$VERSION_CODENAME”) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo systemctl enable –now docker ```
For Ubuntu, replace `/linux/debian` with `/linux/ubuntu` in the URLs.
Verify Installation
```bash sudo docker run hello-world ```
If successful, you'll see a welcome message from Docker.
Run Docker Without Sudo
```bash sudo usermod -aG docker $USER newgrp docker docker run hello-world ```
This allows you to run Docker commands without sudo.
