How to Install Docker on Ubuntu 22.04

Docker is a containerization platform that allows you to run applications in isolated environments called containers. This allows you to easily deploy and manage your applications, making them more portable and scalable.

Here's a step-by-step guide on how to install Docker on Ubuntu 22.04:

  1. First, make sure you have the latest version of Ubuntu installed on your system.
  2. Update your system's package index:
    sudo apt update
  3. Install the dependencies required to add a new repository over HTTPS:
    sudo apt install apt-transport-https ca-certificates curl software-properties-common
  4. Add the GPG key for the official Docker repository:
    curl -fsSL | sudo apt-key add -
  5. Add the Docker repository to your system's software sources:
    sudo add-apt-repository "deb [arch=amd64] focal stable"
  6. Update your system's package index again:
    sudo apt update
  7. Install Docker:
    sudo apt install docker-ce
  8. Start the Docker service:
    sudo systemctl start docker
  9. Verify that Docker is running:
    sudo systemctl status docker

You should see the message "active (running)" next to the Docker service in the output.

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-12-10 22:37:34 UTC; 13s ago
TriggeredBy: ● docker.socket
   Main PID: 8438 (dockerd)
      Tasks: 7
     Memory: 34.0M
        CPU: 315ms
     CGroup: /system.slice/docker.service
             └─8438 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Additionally, you can verify that Docker is installed correctly by running the hello-world image:

sudo docker run hello-world

This should pull the hello-world image from Docker Hub and run it, displaying a message that says "Hello from Docker!".

That's it! You have successfully installed Docker on Ubuntu 22.04.