Thursday, September 10, 2026

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

 


Docker has become one of the most important tools in modern software development, DevOps, cloud engineering, and system administration.

Whether you are building microservices, running databases, deploying web applications, experimenting with Kubernetes, or setting up an AI development environment, Docker provides a consistent way to package and run applications.

In this guide, we'll install Docker Engine on Ubuntu using Docker's official APT repository.

The process is straightforward and works well for developers, DevOps engineers, SREs, system administrators, and anyone learning containerization.


๐Ÿณ What Is Docker?

Docker is a containerization platform that allows applications and their dependencies to run inside isolated environments called containers.

Instead of installing every application dependency directly onto your Ubuntu system, you can package an application into a container and run it consistently across different environments.

A typical Docker workflow looks like this:

Application
     ↓
Dockerfile
     ↓
Docker Image
     ↓
Docker Container
     ↓
Application Running

For example, instead of installing a database directly on Ubuntu, you could run PostgreSQL inside a Docker container.


๐Ÿงฉ Prerequisites

Before installing Docker, make sure you have:

  • An Ubuntu system
  • Internet connectivity
  • A user with sudo privileges
  • A terminal
  • Basic familiarity with Linux commands

It is also a good idea to update your system before starting.


๐Ÿš€ Step 1: Update Ubuntu

Open Terminal:

Ctrl + Alt + T

Then run:

sudo apt update && sudo apt upgrade -y

This updates the package index and installs available package upgrades.

Depending on how recently your system was updated, this may take a few minutes.


๐Ÿ“ฆ Step 2: Install Required Dependencies

Docker's repository setup requires several supporting packages.

Install them with:

sudo apt install -y ca-certificates curl gnupg lsb-release

These packages provide tools required to securely access and configure external APT repositories.


๐Ÿ” Step 3: Add Docker's Official GPG Key

Create the directory used to store APT repository keys:

sudo mkdir -p /etc/apt/keyrings

Now download Docker's official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

The key allows APT to verify packages obtained from Docker's repository.


๐Ÿ—‚️ Step 4: Add the Docker APT Repository

Next, configure Ubuntu to use Docker's official package repository:

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

This command dynamically detects:

  • Your CPU architecture
  • Your Ubuntu release codename
  • Docker's stable repository

The repository configuration is written to:

/etc/apt/sources.list.d/docker.list

๐Ÿ”„ Step 5: Update the Package Index


Now refresh Ubuntu's package index again:

sudo apt update

At this point, Ubuntu should be able to retrieve package information from Docker's repository.

You can optionally verify that Docker packages are available:

apt-cache policy docker-ce

If the repository is configured correctly, you should see Docker package information.


๐Ÿณ Step 6: Install Docker Engine

Now install Docker Engine and the associated components:

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

This installs several important Docker components.

Docker Engine

docker-ce

The Docker Engine package provides the core container runtime and daemon.

Docker CLI

docker-ce-cli

This provides the docker command-line interface.

containerd

containerd.io

Containerd provides the underlying container runtime infrastructure used by Docker.

Buildx

docker-buildx-plugin

Buildx provides modern Docker image-building functionality.

Docker Compose

docker-compose-plugin

This provides the modern:

docker compose

command.

Notice that modern Docker Compose uses a space:

docker compose

rather than the older:

docker-compose

๐Ÿ” Step 7: Verify Docker Installation

Check the Docker service:

sudo systemctl status docker

You should normally see that the service is:

active (running)

You can also check the Docker version:

docker --version

And verify Docker Compose:

docker compose version

For example:

Docker version ...
Docker Compose version ...

The exact version will depend on the current Docker repository packages.


๐Ÿงช Step 8: Run Your First Docker Container

The easiest way to verify the installation is to run Docker's test image:

docker run hello-world

Docker will:

  1. Check whether the hello-world image exists locally.
  2. Download it if necessary.
  3. Create a container.
  4. Start the container.
  5. Display the test message.
  6. Exit the container.

If everything is working correctly, you should see:

Hello from Docker!

๐ŸŽ‰ Your Docker installation is working!


๐Ÿ‘ค Step 9: Run Docker Without sudo

By default, Docker commands may require administrative privileges depending on how your system is configured.

For example:

sudo docker ps

If you want your current user to execute Docker commands without sudo, add the user to the Docker group:

sudo usermod -aG docker $USER

Then apply the new group membership to your current shell:

newgrp docker

Now try:

docker ps

If the configuration is correct, you should no longer need:

sudo

⚠️ Important Docker Permission Warning

Adding your user to the docker group is convenient, but it has a significant security implication.

Membership in the Docker group effectively provides root-level control over the host system because Docker can be used to create containers with powerful access to the host.

Therefore:

Only add trusted users to the Docker group.

For a personal development machine, this is commonly acceptable. On a shared or security-sensitive server, evaluate the implications carefully.


๐Ÿ”„ Check Whether Docker Starts Automatically

Docker is normally configured as a system service.

You can check its status with:

systemctl status docker

You can also check whether it is enabled at boot:

systemctl is-enabled docker

If necessary, enable it:

sudo systemctl enable --now docker

This both enables Docker at boot and starts it immediately.


๐Ÿงฐ Useful Docker Commands

Once Docker is installed, these commands are worth learning.

List running containers

docker ps

List all containers

docker ps -a

List downloaded images

docker images

Download an image

docker pull ubuntu

Run an Ubuntu container

docker run -it ubuntu bash

Stop a container

docker stop <container_name_or_id>

Remove a container

docker rm <container_name_or_id>

Remove an image

docker rmi <image_name_or_id>

View Docker information

docker info

View Docker disk usage

docker system df

๐Ÿงฉ Docker Compose

Docker Compose becomes especially useful when your application consists of multiple services.

For example:

Web Application
      │
      ├── PostgreSQL
      │
      ├── Redis
      │
      └── API

Instead of manually starting every container, you can define the entire application stack in a compose.yaml file.

For example:

services:
  web:
    image: nginx
    ports:
      - "8080:80"

Start it with:

docker compose up -d

Check the services:

docker compose ps

Stop them with:

docker compose down

๐Ÿ› ️ Common Problems

Docker command not found

If you receive:

docker: command not found

verify that Docker was installed:

apt-cache policy docker-ce

Then check:

which docker

Docker Service Isn't Running

Check:

sudo systemctl status docker

Try starting it:

sudo systemctl start docker

Then test:

docker run hello-world

Permission Denied

If:

docker ps

returns a permission error, try:

sudo usermod -aG docker $USER
newgrp docker

Then:

docker ps

If the new group membership has not propagated as expected, log out and log back in.


๐Ÿ” Docker Security Best Practices

Installing Docker is only the beginning. If you plan to use Docker on a production or Internet-facing server, security deserves additional attention.

Consider:

  • Using trusted container images
  • Keeping Docker updated
  • Avoiding unnecessary privileged containers
  • Limiting exposed ports
  • Reviewing mounted host directories
  • Using least-privilege application users
  • Scanning images for vulnerabilities
  • Configuring firewall rules
  • Avoiding unnecessary Docker socket exposure
  • Keeping secrets out of Dockerfiles and images

A particularly important rule is:

Never expose the Docker daemon's control interface to the Internet without understanding the security consequences.


๐Ÿš€ What Can You Do After Installing Docker?

Once Docker is running, Ubuntu becomes an excellent platform for experimenting with modern infrastructure.

You can run:

Development

  • Python applications
  • Node.js
  • Java
  • Go
  • .NET

Databases

  • PostgreSQL
  • MySQL
  • MongoDB
  • Redis

DevOps

  • Jenkins
  • GitLab
  • Prometheus
  • Grafana

AI/ML

  • Ollama
  • Jupyter
  • AI APIs
  • GPU-enabled workloads
  • Model-serving infrastructure

Infrastructure

  • Nginx
  • Apache
  • Kubernetes components
  • Message queues
  • Microservices

This makes Docker particularly useful for developers, SREs, cloud engineers and system administrators.


๐Ÿ“‹ Complete Installation Command List

For quick reference:

# Update Ubuntu
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install -y ca-certificates curl gnupg lsb-release

# Add Docker GPG key
sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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

# Update package index
sudo apt update

# Install Docker
sudo apt install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin

# Verify
sudo systemctl status docker
docker --version
docker compose version

# Optional: use Docker without sudo
sudo usermod -aG docker $USER
newgrp docker

# Test
docker run hello-world

๐ŸŽฏ Conclusion

Installing Docker on Ubuntu doesn't have to be complicated.

By using Docker's official APT repository, you can install Docker Engine, Docker CLI, containerd, Buildx and Docker Compose and quickly start running containers.

The basic workflow is:

Update Ubuntu
     ↓
Install Dependencies
     ↓
Add Docker GPG Key
     ↓
Add Docker Repository
     ↓
Install Docker
     ↓
Verify Installation
     ↓
Run hello-world
     ↓
Start Building Containers ๐Ÿš€

Once docker run hello-world successfully displays "Hello from Docker!", your Ubuntu system is ready for the next stage of container-based development.

The real power of Docker begins after installation—when you start building images, creating Compose stacks, networking containers, managing persistent volumes, securing deployments, and integrating containers into CI/CD and cloud infrastructure.



๐Ÿท️ Tags

Docker, Docker Ubuntu, Install Docker Ubuntu, Docker Installation, Docker Engine, Docker CLI, Docker Compose, Docker Compose Ubuntu, Docker Buildx, Containerd, Ubuntu Tutorial, Linux Tutorial, Docker Tutorial, Linux Containers, Containerization, DevOps, Docker DevOps, SRE, Cloud Computing, Linux Administration, Ubuntu Server, Docker Commands, Docker Beginner Guide, Docker Security, Docker Permissions, Docker Compose Tutorial, Docker for Beginners, Container Technology

#️⃣ Hashtags

#Docker, #DockerUbuntu, #DockerEngine, #DockerCompose, #DockerTutorial, #Ubuntu, #UbuntuLinux, #Linux, #LinuxTutorial, #LinuxContainers, #Containerization, #DevOps, #SRE, #CloudComputing, #DockerSecurity, #UbuntuServer, #DockerBeginner, #LinuxAdministration

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

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

  Docker has become one of the most important tools in modern software development, DevOps, cloud engineering, and system administration. Wh...