How to install docker on Linux

Last updated on May 27 2022
Raigiri Patil

Table of Contents

How to install docker on Linux

Installing Docker on Linux

To start the installation of Docker, we are going to use an Ubuntu instance. You can use Oracle Virtual Box to setup a virtual Linux instance, in case you don’t have it already.

The subsequent screenshot shows a simple Ubuntu server which has been installed on Oracle Virtual Box. There is an OS user named demo which has been defined on the system having entire root access to the sever.

Page 1 Image 1 50
Root server access

To install Docker, we would like to follow the steps given below.

Step 1 − Before installing Docker, you first have to ensure that you have the right Linux kernel version running. Docker is only designed to run on Linux kernel version 3.8 and higher. We can do this by running the subsequent command.

uname

This method returns the system information about the Linux system.

Syntax

uname -a

Options

a − This is employed to ensure that the system information is returned.

Return Value

This method returns the subsequent information on the Linux system −

  • kernel name
  • node name
  • kernel release
  • kernel version
  • machine
  • processor
  • hardware platform
  • operating system

Example

uname –a

Output

When we run above command, we will get the subsequent result −

Page 2 Image 2 45
Subsequent Result

From the output, we can see that the Linux kernel version is 4.2.0-27 which is higher than version 3.8, so we are good to go.

Step 2 − You would like to update the OS with the latest packages, which can be done via the subsequent command −

apt-get

This method installs packages from the Internet on to the Linux system.

Syntax

sudo apt-get update

Options

  • sudo − The sudo command is employed to ensure that the command runs with root access.
  • update − The update option is employed ensure that all packages are updated on the Linux system.

Return Value

None

Example

sudo apt-get update

Output

When we run the above command, we will get the subsequent result −

Page 3 Image 3 19
Update

This command will connect to the internet and download the latest system packages for Ubuntu.

Step 3 − The next step is to install the necessary certificates that will be required to work with the Docker site later on to download the necessary Docker packages. It can be done with the subsequent command.

sudo apt-get install apt-transport-https ca-certificates

Page 4 Image 4 13
Certificate

Step 4 − The next step is to add the new GPG key. This key is required to ensure that all data is encrypted when downloading the necessary packages for Docker.

The subsequent command will download the key with the ID 58118E89F3A912897C070ADBF76221572C52609D from the keyserver hkp://ha.pool.sks-keyservers.net:80 and adds it to the adv keychain. Please note that this particular key is required to download the necessary Docker packages.

Page 4 Image 5 16
Docker Package

Step 5 − Next, depending on the version of Ubuntu you have, you will would like to add the relevant site to the docker.list for the apt package manager, so that it will be able to detect the Docker packages from the Docker site and download them accordingly.

  • Precise 12.04 (LTS) ─ deb https://apt.dockerproject.org/repoubuntu-precise main
  • Trusty 14.04 (LTS) ─ deb https://apt.dockerproject.org/repo/ ubuntu-trusty main
  • Wily 15.10 ─ deb https://apt.dockerproject.org/repo ubuntu-wily main
  • Xenial 16.04 (LTS) – https://apt.dockerproject.org/repo ubuntu-xenial main

Since our OS is Ubuntu 14.04, we will use the Repository name as “deb https://apt.dockerproject.org/repoubuntu-trusty main”.

And then, we will would like to add this repository to the docker.list as mentioned above.

echo “deb https://apt.dockerproject.org/repo ubuntu-trusty main”    | sudo tee /etc/apt/sources.list.d/docker.list

Page 5 Image 6 12
Docker List

Step 6 − Next, we issue the apt-get update command to update the packages on the Ubuntu system.

Page 5 Image 7 9
getupdate

Step 7 − If you want to verify that the package manager is pointing to the right repository, you can do it by issuing the apt-cache command.

apt-cache policy docker-engine

Within the output, you will get the link to https://apt.dockerproject.org/repo/

Page 6 Image 8 8
policy

Step 8 − Issue the apt-get update command to ensure all the packages on the local system are up to date.

Page 7 Image 9 6
aptgetupdate

Step 9 − For Ubuntu Trusty, Wily, and Xenial, we have to install the linux-image-extra-* kernel packages, which allows one to use the aufs storage driver. This driver is employed by the newer versions of Docker.

It can be done by using the subsequent command.

sudo apt-get install linux-image-extra-$(uname -r)    linux-image-extra-virtual

Page 8 Image 10 2
imageextravisual

Step 10 − The final step is to install Docker and we can do this with the subsequent command −

sudo apt-get install –y docker-engine

Here, apt-get uses the install option to download the Docker-engine image from the Docker website and get Docker installed.

The Docker-engine is the official package from the Docker Corporation for Ubuntu-based systems.

Page 9 Image 11 1
dockerinstall

Within the next section, we will see how to check for the version of Docker that was installed.

Docker Version

To see the version of Docker running, you can issue the subsequent command −

Syntax

docker version

Options

  • version − It is employed to ensure the Docker command returns the Docker version installed.

Return Value

The output will provide the various details of the Docker version installed on the system.

Example

sudo docker version

Output

When we run the above program, we will get the subsequent result −

Page 10 Image 12 1
dockerversion

Docker Info

To see more information on the Docker running on the system, you can issue the subsequent command −

Syntax

docker info

Options

  • info − It is employed to ensure that the Docker command returns the detailed information on the Docker service installed.

Return Value

The output will provide the various details of the Docker installed on the system such as −

  • Number of containers
  • Number of images
  • The storage driver employed by Docker
  • The root directory employed by Docker
  • The execution driver employed by Docker

Example

sudo docker info

Output

When we run the above command, we will get the subsequent result −

Page 11 Image 13 1
dockerinfo

So, this brings us to the end of blog. This Tecklearn ‘How to install Docker on Linux’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Docker and build a career in DevOps domain, then check out our interactive, Containerization using Docker Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/containerization-using-docker/

Containerization using Docker Training

About the Course

Tecklearn has specially designed this Containerization using Docker Training Course to advance your skills for a successful career in this domain. his Docker training online course will help you learn Docker containerization, running Docker containers, Docker image creation, Dockerfile, Docker orchestration, security best practices and more through hands-on projects and case studies. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Docker.

Why Should you take Containerization using Docker Training?

  • Average salary of Docker Expert is $110k – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.
  • Intuit, PayPal, Splunk, Uber & many other MNC’s worldwide use Docker across industries

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Containerization using Docker – Part 1

  • Introduction to Docker
  • Understanding Docker Lifecycle
  • Docker Architecture
  • Components of Docker Ecosystem
  • Common Docker Operations
  • Committing changes in a Container
  • Hands On

Containerization using Docker – Part 2

  • Building Custom Docker Images
  • Docker Image
  • Introduction to Docker Swarm
  • Deploying a 2-Node Cluster using Docker Swarm
  • Hands on

 

0 responses on "How to install docker on Linux"

Leave a Message

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