• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to install Docker on Ubuntu

June 7, 2020 by Sharad Chhetri

In this post, we will learn how to install Docker on Ubuntu 22.04 LTS, 20.04 LTS, 18.04 LTS and 16.04 LTS. We have installed the Docker by using shell script in Ubuntu Operating System. We will use the recommended steps and commands to install docker on Ubuntu. We have clubbed all the recommended commands in our shell script for installing Docker.

Brief Introduction

Docker is a container platform software, by using Docker we can create containers.  Through Docker we can easily manage the containers and that is the reason it is quite popular. 

Requirements

Here are the requirements for installing Docker.
1. 64 Bit Operating System: Docker Engine is supported on x86_64 (or amd64), armhf, arm64, s390x (IBM Z), and ppc64le (IBM Power) architectures

2. Operating System (We recommend to use LTS):

  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Bionic 18.04 (LTS)
  • Ubuntu Xenial 16.04 (LTS)

Note:
Remove the docker if it is already installed.

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

Steps To Install Docker On Ubuntu

Create a file which will be the docker installation script.

vi install_docker_ubuntu.sh

Paste the following content in the file.

#!/bin/bash
# Description: Install docker on Ubuntu
# Blog: https://sharadchhetri.com
#
# Docker Supported Architecture: x86_64 (or amd64), armhf, arm64, s390x and ppc64le
#

_arch=$(dpkg --print-architecture)
sudo apt -y update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

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

sudo apt-get -y update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker ${USER}

Give executable permission to the shell script.

sudo chmod +x install_docker_ubuntu.sh

Run the script, it will install the docker on Ubuntu.

sh install_docker_ubuntu.sh

Because we have added the current login user to group ‘docker’. To make it effective either logout or restart the system. Here we prefer to reboot the system.

sudo init 6

You can check the docker version by running the command docker --version

Output from our system

sharad@linuxworld:~$ docker --version
Docker version 19.03.11, build 42e35e61f3
sharad@linuxworld:~$ 

You can just pull any image for testing purpose also. For example, here we have pulled the ‘httpd’ image.

sharad@linuxworld:~$ docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
afb6ec6fdc1c: Pull complete 
5a6b409207a3: Pull complete 
41e5e22239e2: Pull complete 
9829f70a6a6b: Pull complete 
3cd774fea202: Pull complete 
Digest: sha256:590382d0aca313c3b0dbfd7c45afe92c76a729cceab3c8555edc03761b2b1b93
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest
sharad@linuxworld:~$ 

If all looks good, the docker is ready to use in your system.

git You can Git pull this script from our Github Repo called ‘scripts’. 

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to create Ubuntu docker base image
  2. Install Docker on CentOS 7
  3. How to install Docker on CentOS 8
  4. Install XFCE Desktop in Ubuntu through command line
  5. How to install flash player plugin in Ubuntu
  6. How to install Apache Web Server on Ubuntu 14.04 LTS (Trusty Tahr)
  7. How to install Owncloud 6 on Ubuntu 14.04 LTS Server
  8. How to install KVM on Ubuntu 16.04 LTS Desktop
  9. Install Ansible in Ubuntu 18.04 LTS with pip3
  10. Install Vagrant on Ubuntu and create first VM

Filed Under: Linux, Containers, Docker Tagged With: container, docker, ubuntu

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Keep logs of user after sudo su – : Secondary Logging

Replace keyword with its filename without extension : bash script

Learn Linux Date Command With Examples

This kernel requires an x86-64 CPU but only detected an i686 CPU

send email after mysql backup through bash script in simple way

SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

Nagios HTTP WARNING: HTTP/1.1 403 Forbidden

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy