News & Updates

How to Install Docker on Ubuntu: Step-by-Step Guide

By Noah Patel 3 Views
how to install docker ubuntu
How to Install Docker on Ubuntu: Step-by-Step Guide

Running applications in isolated environments is a fundamental practice for modern development and deployment workflows. Docker provides a powerful platform for creating, deploying, and running applications using containers on an Ubuntu server.

Understanding Docker and Its Benefits on Ubuntu

Docker packages an application and its dependencies into a standardized unit for software development. On Ubuntu, this technology leverages the Linux kernel's native capabilities like namespaces and control groups. This isolation ensures consistency across development, testing, and production environments. You can run multiple applications securely on the same host without conflicts.

Prerequisites for Installing Docker

Before you begin the installation, ensure your Ubuntu system meets specific requirements. You need a 64-bit version of Ubuntu with a kernel version of 3.10 or newer. It is also recommended to have a non-root user with sudo privileges configured for security best practices.

Updating Your System Packages

Start by updating the local package index to ensure you are installing the latest available versions. Open your terminal and run the update command to refresh the repository lists. This step helps prevent dependency issues during the Docker installation process.

sudo apt update

Installing the Docker Engine

The Docker Engine is the core component that allows you to create and run containers. The official Docker repository provides the most recent version of the software for Ubuntu. Adding this repository ensures you receive stable updates and security patches promptly.

Adding the Docker GPG Key and Repository

To verify the integrity of the packages, you must first add the official Docker GPG key. Then, you will add the stable Docker repository to your system's sources list. This configuration allows your package manager to pull Docker packages directly from the source.

sudo apt-get install ca-certificates curl gnupg

sudo install -m 0755 -d /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable"
\ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Installing the Latest Docker Packages

With the repository configured, you can now install the Docker Engine, CLI, and containerd runtime. Updating the apt cache again pulls the package lists from the newly added Docker repository. The installation process will download and set up all necessary components automatically.

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Managing the Docker Service

Once the installation completes, the Docker daemon starts automatically. You can verify that the service is running correctly without any manual intervention. Checking the status provides confidence that the environment is ready for use.

sudo systemctl status docker

Executing Commands Without Sudo

By default, running Docker commands requires sudo privileges because the daemon socket is owned by the root user. Adding your standard user to the Docker group eliminates the need to prepend every command with sudo. This change improves workflow efficiency and reduces potential typos with elevated permissions.

sudo usermod -aG docker $USER

N

Written by Noah Patel

Noah Patel is a Senior Editor focused on business, technology, and markets. He favors data-backed analysis and plain-language explanations.