DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Install Docker on Ubuntu
Saravanan Gnanaguru for Kubernetes Community Days Chennai

Posted on • Updated on • Originally published at dev.to

Install Docker on Ubuntu

Install Docker on Ubuntu

Table of Content

Introduction

  • We will see how to install docker on Ubuntu, in this article
  • Purpose of this tutorial is to provide the comprehensive steps focusing on the installation and verification of Docker on Ubuntu
  • This blog is a repost of my same blog published in dev.to

Steps to Install Docker Explained

  • Setup the Repository
  • Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get install  apt-transport-https ca-certificates curl     gnupg-agent software-properties-common
Enter fullscreen mode Exit fullscreen mode
  • Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode
# Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

sudo apt-key fingerprint 0EBFCD88
Enter fullscreen mode Exit fullscreen mode
  • Set up the stable repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Enter fullscreen mode Exit fullscreen mode
  • Install Docker Engine
# Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Enter fullscreen mode Exit fullscreen mode
  • Verify that Docker Engine Installation
# Verify Docker Is installed correctly by running the hello-world image.
sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Installation as Shell Script

# SET UP THE REPOSITORY
# Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update -y 
sudo apt-get remove -y docker docker-engine docker.io containerd runc
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

# Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88, 
# by searching for the last 8 characters of the fingerprint.
sudo apt-key fingerprint 0EBFCD88

# Use the following command to set up the stable repository. 
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

# Update the apt package index, and install the latest version of Docker Engine and containerd, 
# or go to the next step to install a specific version:
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

# Verify that Docker Engine is installed correctly by running the hello-world image.
sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Docker run output of Hello World

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
Enter fullscreen mode Exit fullscreen mode

Bibliography

This article is inspired from the Docker installation documentation
Issue: socket permission denied. Resolution

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.