LightYear
/Docs
DocsComputeInstall Docker on Ubuntu 22.04

Install Docker on Ubuntu 22.04

Install Docker Engine and Docker Compose on Ubuntu 22.04 and run your first container.

beginner
8 min read
LightYear Docs Team
Updated April 24, 2026
dockercontainersubuntudevops
Ready to get started?

Docker is a platform for building, shipping, and running containerised applications. This guide installs Docker Engine and Docker Compose on Ubuntu 22.04.

Prerequisites

  • Ubuntu 22.04 server with sudo privileges
  • At least 2 GB RAM recommended

Step 1 — Remove Old Docker Versions

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

Step 2 — Install Dependencies

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

Step 3 — Add Docker's GPG Key and Repository

>_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
>_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 4 — Install Docker Engine

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

Step 5 — Verify the Installation

>_BASH
$docker --version
OUTPUT
Docker version 26.1.4, build 5650f9b
>_BASH
$docker run hello-world
OUTPUT
Hello from Docker!
This message shows that your installation appears to be working correctly.

Step 6 — Run Docker Without Sudo

Add your user to the docker group:

>_BASH
$usermod -aG docker deploy
$newgrp docker

Step 7 — Enable Docker on Boot

>_BASH
$systemctl enable docker
$systemctl enable containerd

Step 8 — Install Docker Compose (Standalone)

>_BASH
$curl -SL "https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
$chmod +x /usr/local/bin/docker-compose
$docker-compose --version
OUTPUT
Docker Compose version v2.27.1

Run a Sample Application

Create a docker-compose.yml for a simple Nginx web server:

YAML
version: '3.8'
services:
  web:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    restart: unless-stopped
>_BASH
$mkdir html && echo "<h1>Hello from Docker!</h1>" > html/index.html
$docker-compose up -d
>_BASH
$curl http://localhost
OUTPUT
<h1>Hello from Docker!</h1>

[!NOTE] Remember to open port 80 in your LightYear firewall group if you want to access the web server from the internet.

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