Tell me for any kind of development solution

Edit Template

How to Install Docker on Ubuntu 22.04: A Complete Guide

Docker is a leading containerization platform that simplifies building, deploying, and managing applications in isolated environments called containers. Whether you’re a developer or DevOps engineer, installing Docker on Ubuntu 22.04 unlocks efficient workflows for creating portable, scalable apps.

In this guide, you’ll learn how to install Docker on Ubuntu 22.04, verify the setup, manage containers, and even push custom images to Docker Hub. Let’s dive in!. Also, explore installing LEMP in Ubuntu.

Why Use Docker on Ubuntu 22.04?

Containers package applications with their dependencies, ensuring consistency across environments. Unlike virtual machines, Docker containers are lightweight, fast, and share the host OS kernel. Ubuntu 22.04 (Jammy Jellyfish) offers robust support for Docker, making it ideal for development and production.

Prerequisites

  • An Ubuntu 22.04 system.
  • A user with sudo privileges.
  • Terminal access.

Step 1: Update System Packages

Start by updating your package list to ensure you’re installing the latest versions:

sudo apt update && sudo apt upgrade -y  

Step 2: Install Required Dependencies

Install packages to allow apt to use HTTPS repositories:

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y  

Step 3: Add Docker’s Official Repository

1. Add Docker’s GPG Key (secure method):

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg  

2. Add the Docker Repository for Ubuntu 22.04:

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

3. Update the package index again:

sudo apt update  

Step 4: Install Docker on Ubuntu 22.04

Install the Docker Community Edition (CE) packages:

sudo apt install docker-ce docker-ce-cli containerd.io -y  

Step 5: Verify the Installation

Check if Docker is running:

sudo systemctl status docker  

![Docker Service Status](image-url.jpg “Check Docker service status on Ubuntu 22.04” Alt text: “Docker service active and running on Ubuntu 22.04”)


Step 6: Run Docker Without Sudo (Optional)

Avoid typing sudo with every Docker command by adding your user to the docker group:

sudo usermod -aG docker $USER 
newgrp docker  # Reload group membership without logging out  

Verify permissions:

docker run hello-world  

Expected Output: A “Hello from Docker!” confirmation message.


Step 7: Manage Docker Containers

Basic Docker Commands

List running containers:

docker ps  

List all containers (including stopped):

docker ps -a  

Start/Stop a container:

docker start <container_id> 
docker stop <container_id>  

Step 8: Pull and Run Custom Images

1. Download an Ubuntu image:

docker pull ubuntu  

2. Run an interactive shell:

docker run -it ubuntu /bin/bash  

Step 9: Push Images to Docker Hub (Optional)

1. Log in to Docker Hub:

docker login -u your-dockerhub-username  

2. Tag and push your image:

docker tag local-image:tag your-dockerhub-username/image-name:tag 
docker push your-dockerhub-username/image-name:tag  

Troubleshooting Common Issues

  • Permission denied: Ensure your user is in the docker group.
  • Docker service not starting: Use sudo systemctl restart docker.

Conclusion

You’ve successfully installed Docker on Ubuntu 22.04 and learned essential commands to manage containers. Docker streamlines app deployment, making it a must-have tool for modern development.

Need Help? Share your questions below, or explore our guide on Essential Docker Commands for Beginners to level up your skills!

Share Article:

© 2025 Created by ArtisansTech