LightYear
/Docs
DocsComputeInstall Docker on Ubuntu 22.04

Install Docker on Ubuntu 22.04

Install Docker Engine and Docker Compose on a fresh Ubuntu 22.04 server.

beginner
7 min read
LightYear Team
Updated April 24, 2026
dockerubuntucontainers
Ready to get started?

Overview

Docker allows you to package applications into portable containers. This guide installs Docker Engine (not Docker Desktop) on Ubuntu 22.04.

Step 1 — Remove Old Versions

>_BASH
$apt-get remove -y docker docker-engine docker.io containerd runc

Step 2 — Install Prerequisites

>_BASH
$apt-get update
$apt-get install -y ca-certificates curl gnupg lsb-release

Step 3 — Add Docker's GPG Key

>_BASH
$install -m 0755 -d /etc/apt/keyrings
$curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$chmod a+r /etc/apt/keyrings/docker.gpg

Step 4 — Add the Repository

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

Step 5 — Install Docker Engine

>_BASH
$apt-get update
$apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 6 — Verify Installation

>_BASH
$docker run hello-world

Step 7 — Run Docker Without sudo (Optional)

>_BASH
$usermod -aG docker $USER
$newgrp docker

Install Docker Compose (Standalone)

>_BASH
$curl -SL https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
$chmod +x /usr/local/bin/docker-compose
$docker-compose version

Enable Docker on Boot

>_BASH
$systemctl enable docker
$systemctl start docker

Was this article helpful?

Your cookie choices for this website

This site uses cookies and related technologies, as described in our privacy policy, for purposes that may include site operation, analytics, and enhanced user experience. You may choose to consent to our use of these technologies, or manage your own preferences. Cookie policy