How can I install Docker on Ubuntu Linux distribution. Docker Engine is a container runtime engine which allows you to package your applications with all of its dependencies into a standardized unit for software development and distribution.

The Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Docker support image versioning thus allowing you to run multiple versions of the application with ease. By taking advantage of its seamless integration with Docker Hub you can publish and share container images with your team. If you want to share files or persist data storage on the host file system then this is also possible by mounting volumes.

Let’s install Docker CE on Ubuntu by following the few steps below.

1. Update System

Ensure your system is updated.

sudo apt -y update

2. Install basic dependencies

There are few dependencies we need to configure Docker repositories and do the actual package installation. Install them by firing the following commands in your terminal.

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

3. Install Docker CE

If you have older versions of Docker, remove it and its dependent packages.

sudo apt remove docker docker-engine docker.io containerd runc

Import Docker repository GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg

You can then add Docker CE repository to Ubuntu

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Finally install Docker CE on Ubuntu:

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

Start and enable docker service.

sudo systemctl enable docker && sudo systemctl start docker

Add your user account to docker group.

sudo usermod -aG docker $USER
newgrp docker

Verify installation by checking Docker version:

$ docker version
Client: Docker Engine - Community
 Version:           27.0.3
 API version:       1.46
 Go version:        go1.21.11
 Git commit:        7d4bcd8
 Built:             Sat Jun 29 00:02:23 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.0.3
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       662f78c
  Built:            Sat Jun 29 00:02:23 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.18
  GitCommit:        ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc:
  Version:          1.7.18
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

4. Install Docker Compose

Installation of Docker Compose is optional. For those using it, follow our guide below to install.

5. Installing Docker UI

If you need a UI based application for managing containers check out Portainer in the following link:

More articles:

2 COMMENTS

  1. I initially got the following error when I ran “docker version”:
    “Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?”

    So I ran “sudo systemctl start docker”, then ran “docker version”, and I was able to get the correct system output.

LEAVE A REPLY

Please enter your comment!
Please enter your name here