Index Keywords

↶ Return

Installing Docker on Ubuntu

Background

The following steps outline how to install Docker Engine on Ubuntu.

Requirements

  • OS
    • Ubuntu Impish 21.10
    • Ubuntu Hirsute 21.04
    • Ubuntu Focal 20.04 (LTS)
    • Ubuntu Bionic 18.04 (LTS)

Installation

Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

Setup the Repo

Run the following commands to prepare:[1]

1
2
3
4
5
6
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add Docker’s official GPG key:

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

Configure the repo:

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

Install the Docker Engine

1
2
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

Post-Install Configuration

Once that completes, run the following commands to allow docker to run as non-root:[2]

1
2
3
$ sudo groupadd docker
$ sudo usermod -aG docker $USER
$ newgrp docker

Sources


  1. Title: Docker Docs: Install on Ubuntu
    Publication: Docker Docs ↩︎

  2. Title: Docker Docs: Post-Install for Linux
    Publication: Docker Docs ↩︎