• 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 Leave a Comment

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 pdfedit for editing pdf file in Ubuntu
  5. How to install Nagios 4 from source on Ubuntu 14.04 LTS
  6. Install Ansible in Ubuntu 18.04 LTS with pip3
  7. Install VirtualBox on Ubuntu
  8. Install Vagrant on Ubuntu and create first VM
  9. Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)
  10. How To Always Install Latest Git Package In Ubuntu Operating System

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

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

There are unfinished transactions remaining. You might consider running yum-complete-transaction

semanage command not found in CentOS 6 and RHEL 6

Unix / Linux : How to print duplicate lines from file

yum : how to find rpm package which has certain command or file

semanage command not found on CentOS 7 and RHEL 7

How to test rpm package before installation

How to free pagecache, dentries and inodes from memory on linux

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

postgres database backup script using database user password inside

How to put slider shortcode only in home page in WordPress

How to zip directory in linux explained with examples

Forgot root password ,Reset it in Run level 1

Nagios HTTP WARNING: HTTP/1.1 403 Forbidden

How to page scroll up/down in Linux terminal

Virtual Machine inaccessible status on VirtualBox 4.3

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

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)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

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