Installing Docker on Linux (2024)

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 following 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.

Installing Docker on Linux (1)

To install Docker, we need 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 following command.

uname

This method returns the system information about the Linux system.

Syntax

uname -a

Options

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

Return Value

This method returns the following 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 following result −

Installing Docker on Linux (2)

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 need to update the OS with the latest packages, which can be done via the following command −

apt-get

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

Syntax

sudo apt-get update

Options

Return Value

None

Example

sudo apt-get update

Output

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

Installing Docker on Linux (3)

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 following command.

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

Installing Docker on Linux (4)

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 following 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.

Installing Docker on Linux (5)

Step 5 − Next, depending on the version of Ubuntu you have, you will need 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.

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 need 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

Installing Docker on Linux (6)

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

Installing Docker on Linux (7)

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

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

Installing Docker on Linux (8)

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

Installing Docker on Linux (9)

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 used by the newer versions of Docker.

It can be done by using the following command.

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

Installing Docker on Linux (10)

Step 10 − The final step is to install Docker and we can do this with the following 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.

Installing Docker on Linux (11)

In 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 following command −

Syntax

docker version 

Options

  • version − It is used 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 following result −

Installing Docker on Linux (12)

Docker Info

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

Syntax

docker info

Options

  • info − It is used 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 used by Docker
  • The root directory used by Docker
  • The execution driver used by Docker

Example

sudo docker info

Output

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

Installing Docker on Linux (13)

Docker for Windows

Docker has out-of-the-box support for Windows, but you need to have the following configuration in order to install Docker for Windows.

System Requirements

Windows OSWindows 10 64 bit
Memory2 GB RAM (recommended)

You can download Docker for Windows from − https://docs.docker.com/docker-for-windows/

Installing Docker on Linux (14)

Docker ToolBox

Docker ToolBox has been designed for older versions of Windows, such as Windows 8.1 and Windows 7. You need to have the following configuration in order to install Docker for Windows.

System Requirements

Windows OSWindows 7 , 8, 8.1
Memory2 GB RAM (recommended)
VirtualizationThis should be enabled.

You can download Docker ToolBox from − https://www.docker.com/products/docker-toolbox

Installing Docker on Linux (15)

Advertisem*nts

Installing Docker on Linux (2024)

FAQs

How to install docker in Linux step by step? ›

Go to https://download.docker.com/linux/ubuntu/dists/ .
  1. Select your Ubuntu version in the list.
  2. Go to pool/stable/ and select the applicable architecture ( amd64 , armhf , arm64 , or s390x ).
  3. Download the following deb files for the Docker Engine, CLI, containerd, and Docker Compose packages: ...
  4. Install the .deb packages.

What kind of Linux must you have to install docker on Linux? ›

The script installs Docker CE (Community Edition), assuming you are using one of the following Linux distributions, or a derivative: CentOS. Debian. Fedora.

What is the difference between docker desktop and docker in Linux? ›

Docker Engine is the fundamental containerization engine that runs on servers and manages containers, while Docker Desktop is a developer-focused tool that includes Docker Engine along with additional features to simplify the development and testing of containerized applications on local machines.

Do I really need docker desktop? ›

If you are running containers on a Windows client machine, Docker Desktop is likely the preferred option to run containers. You can run both Windows and Linux containers, albeit, not at the same time.

How to install Docker correctly? ›

After downloading Docker Desktop Installer.exe , run the following command in a terminal to install Docker Desktop:
  1. $ "Docker Desktop Installer.exe" install. If you're using PowerShell you should run it as:
  2. Start-Process 'Docker Desktop Installer.exe' -Wait install. ...
  3. start /w "" "Docker Desktop Installer.exe" install.

How to install Docker container in Linux? ›

Do this by opening a terminal and typing:
  1. $ which curl.
  2. Step 1.1. ...
  3. $ curl -fsSL https://get.docker.com/ | sh.
  4. sudo usermod -aG docker <your_username>

How to install and configure Docker on Linux? ›

Be sure to follow these steps carefully:
  1. First, you should update your list of packages and/or install other necessary packages for the installation of Docker. ...
  2. Add the Docker GPG key to the system using the following command: ...
  3. Add the Docker repository to the system: ...
  4. Update the list of packages and then install Docker:

Does Docker need a VM on Linux? ›

Docker Desktop on Linux runs a Virtual Machine (VM) which creates and uses a custom docker context, desktop-linux , on startup. This means images and containers deployed on the Linux Docker Engine (before installation) are not available in Docker Desktop for Linux.

Can you use Docker without Linux? ›

Does Docker run on Linux, macOS, and Windows? You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64).

Can we run Docker without Docker desktop? ›

Docker Desktop is Docker (the company)'s first wedge into getting you to run proprietary software, so Docker strongly guides you to download it as the only way to get started: In fact, new users can go pretty far without even realizing that you don't need Docker Desktop to run the Docker daemon.

Is it better to run Docker on Windows or Linux? ›

Even though there is no functional difference between Docker on Windows and Linux environments, the installation process on Linux is a bit faster (an apt-get install is quicker than installing a Windows package), and the shell is easier to access on Linux.

Should I install Docker on Windows or Linux? ›

We recommend using Docker Desktop due to its integration with Windows and Windows Subsystem for Linux. However, while Docker Desktop supports running both Linux and Windows containers, you can not run both simultaneously.

Why I don't use Docker? ›

Docker can add complexity and overhead, and it is not always compatible with legacy or specialized software. Additionally, Docker containers are not isolated from the host operating system, so a security breach in one container could potentially affect other containers on the same host.

Why use Docker on Linux? ›

Fast, consistent delivery of your applications

Docker streamlines the development lifecycle by allowing developers to work in standardized environments using local containers which provide your applications and services. Containers are great for continuous integration and continuous delivery (CI/CD) workflows.

Why would anyone use Docker? ›

Docker is popular because it offers portability, consistency, and scalability for deploying applications in different environments. Docker containers are lightweight, isolated, and easy to deploy, making them a popular choice for modern application development and deployment. What language was used to write Docker?

How to install docker in Linux using command line? ›

Installing Docker on Linux
  1. $ which curl.
  2. Step 1.1. ...
  3. $ curl -fsSL https://get.docker.com/ | sh.
  4. sudo usermod -aG docker <your_username>

Can we install docker in Linux? ›

To install Docker Desktop successfully, your Linux host must meet the following general requirements: 64-bit kernel and CPU support for virtualization. KVM virtualization support.

How to install and configure docker on Linux? ›

Be sure to follow these steps carefully:
  1. First, you should update your list of packages and/or install other necessary packages for the installation of Docker. ...
  2. Add the Docker GPG key to the system using the following command: ...
  3. Add the Docker repository to the system: ...
  4. Update the list of packages and then install Docker:

How to start docker in Linux command? ›

The command systemctl --user start docker-desktop it's start the Docker with the CLI.

Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 6555

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.