In our final tutorial, we have discussed the fundamentals of Docker . To brainstorm experimenting with Docker, like learning the commands, working with Docker, and deploying applications, we need get-go to install Docker on our machine. Almost all operating systems support Docker, merely we need to follow a specific sequence of installation. In this tutorial, we volition discuss the installation of Docker on Windows and Linux. In improver, Docker Engine is supported by the following platforms.

  1. Linux.
  2. Windows Bone.
  3. macOS.

Windows and Mac OS offering Docker installation through " Docker Desktop ". In addition, Docker provides " .rpm " or " .deb " packages for Linux architectures and distributions for various Linux versions.

After, we will be discussing the post-obit topics in this article:

  • How to install Docker in Linux?
    • System Requirements/Prerequisites.
    • How to Install Docker on Ubuntu?
    • How to Uninstall Docker?
    • And, how to install Docker on other Linux versions?
  • How to Install Docker on Windows?
    • Prerequisites for installing Docker on Windows.
    • How to install Docker Desktop on Windows?
    • And, how to uninstall Docker Desktop on Windows?
  • How to Install Docker on macOS?
    • And, how to uninstall Docker on macOS?

How to install Docker on Linux?

We should ensure that we fulfill all the prerequisites and/or system requirements before installing Docker in a Linux environment,

Organisation Requirements/Prerequisites

Nosotros should ensure that the Linux machine has satisfied the following requirements.

Check for OS requirements.

To install Docker on Linux, the system should be 64-bit and have i of the post-obit Linux Ubuntu versions installed.

  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Bionic 18.04 (LTS)
  • Or, Ubuntu Xenial xvi.04 (LTS)

The various architectures that support Docker Engine are  x86_64 (amd64), armhf, and arm64.

Uninstall older Docker versions

Next, nosotros need to uninstall whatever older Docker versions on the machine. Older versions of Docker were named docker-engine, docker.io, docker. To uninstall these versions, run the following control.

          $ docker apt-get remove docker docker-engine docker.io containerd runc                  

This command volition remove the Docker software from the machine if any or will requite a message that none were establish.

Configure Driver support

Docker Engine supports overlay2, btrfs, and aufs storage drivers on Ubuntu. By default, Docker Engine uses the overlay2 commuter. So we need to ensure the appropriate drivers are configured. (Normally present on the machine. If we need another like aufs, then we need to manually configure it).

How to Install Docker on Ubuntu?

We tin can install Docker on Ubuntu in iii ways:

  1. Repositories: This is the recommended arroyo. In this approach, nosotros gear up up Docker'due south repositories and install Docker in Ubuntu from these repositories. This approach makes installation likewise as upgrade tasks easier.
  2. Manual Installation: In this approach, users download the "DEB" package and install the docker manually in Ubuntu. This approach tin be adopted when in that location is no access to the cyberspace.
  3. Using automated convenience scripts This approach is mostly used in development and testing environments wherein users use automated convenience scripts to install Docker.

In this commodity, nosotros volition provide a detailed approach to install Docker in Ubuntu by using repositories .

Installing Docker using repositories

We have to set the repository before installing Docker Engine for the first time on a fresh Linux car. And then we tin can install Docker Engine and upgrade it.

The post-obit are steps or sequences of commands to install Docker on an Ubuntu xviii.04 (LTS) machine. Ane tin can repeat these same steps on machines with other versions of Ubuntu.

Set upward the repository for Docker

The following sequence of steps is carried out for setting upwardly the repository.

i.   Update the " apt " package index. For this given the following command.

           $ docker apt-get update                  

The to a higher place command generates the following output. 1-apt-get-update_output.png

Once the " apt " package index is updated, install the packages that allow apt to utilise a repository over HTTPS. For this, execute the following command:

          $ docker apt-get install \     apt-transport-https \     ca-certificates \     roll \     gnupg-amanuensis \     software-properties-common                  

The higher up command will set up the repository. For example, this control gives the post-obit output. 2-Set up repository.png

The higher up screenshot shows the entire process of setting up a repository due to the " sudo apt-get install... " command.

ii.  Once the repository is installed, we have to add and verify Docker's official GPG central.

Note: GPG Key: This is not Docker-specific merely Linux - specific. Using the GPG key, Linux package managers can validate the integrity of the software package being installed by verifying information technology PGP or GPG key. Almost modern Linux distributions come with a set of PGP keys installed for default repositories for that particular distribution. Docker runs its own package repositories for major distribution.

After this, add together Docker's official GPG key with the following command.

          $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-cardinal add -                  

Once the GPG key is added, nosotros can verify it past giving the following control.

          $ docker apt-key fingerprint 0EBFCD88                  

Executing the above commands one after the other generates the following output. 3-VerifyGPGKey.png

In the above screenshot, we can see the GPG key details.

iii. Once our GPG key is added, we can gear up a stable repository of the " nightly " or " test " repository by giving the following command.

          $ docker add together-apt-repository \    "deb [curvation=amd64] https://download.docker.com/linux/ubuntu \    $(lsb_release -cs) \    stable test"                  

This control gives the post-obit output. 4-Install Docker - add repository.png

As seen from the above output, we take used a exam repository here.

Now, nosotros have successfully prepare the repository, and we can proceed with the side by side step of installation of Docker Engine.

Install Docker Engine

First, to install Docker Engine, we update the " apt " bundle and then install the latest version of Docker Engine and 'containerd'.

To update the 'apt' package, we give the same command we accept given in step one.

          $ docker apt-go update                  

One time the apt parcel is updated, we install the latest version of the Docker Engine.

The command is as follows:

          $ docker apt-get install docker-ce docker-ce-cli containerd.io                  

The above command generates the following output. 5-Docker - Install CLI.png

Nosotros can verify if the Docker Engine is successfully installed by issuing the post-obit command that generates the following output (partial output). 6-Verify Docker Installation.png

Or we can requite whatsoever command like

          $ docker run hello-world                  

The higher up control will download a test epitome and run it in a container. Finally, the container will run and print the informational message and exit.

Upgrade Docker Engine

If nosotros need to upgrade the Docker Engine to another version, we once once again need to execute the control.

          docker apt-go update                  

Repeat the above installation instructions further to install the new version.

How to uninstall Docker?

To uninstall the Docker from the Linux machine (with Ubuntu), give the following command.

          $ docker apt-get purge docker-ce docker-ce-cli containerd.io                  

This will uninstall the Docker, CLI, and containerd packages from the machine.

Note that the above command will not remove images, containers, customized configurations, or volumes from the machine . So we need to delete them with the following command explicitly.

          $ docker rm -rf /var/lib/docker                  

Still, if at that place are any boosted configurations, we take to delete them manually.

What are the other Docker installation methods?

Apart from the installation method described above, we tin can apply other installation methods as well.

Below we briefly discuss the other ii methods:

Install Docker from a packet

Although installing Docker using a repository is a recommended method, we tin also install Docker by downloading the " .deb " packet and installing information technology manually.

The steps involved are as follows:

Access the link https://download.docker.com/linux/ubuntu/dists/ .  Navigate to " pool/stable/ " . Select amd64/armf/arm64 and then download the " .deb " file. A screenshot of one of the repository contents is shown below: 7-Docker installers list.png

We tin can select any folder (as per our requirements) from the 'dists' binder, and farther, nosotros tin can see the contents of each repository. For instance, in the to a higher place screenshot, we have selected the " eoan " folder, and then we navigate to the " .deb " file equally explained in the post-obit steps.

Install docker with the post-obit command.

          $ docker dpkg -i /path/to/parcel.deb                  

The path in the command " /path/to/package.deb " should be changed to the appropriate Docker package path.

Equally with the starting time installation method, we tin verify if the Docker is installed correctly using the command.

          $ docker run hello-globe                  

Note: If we need a nightly or exam package, we can do so by replacing the word 'stable' with 'nightly' or 'test'.

Install Docker using Convenience scripts

Installing Docker using Convenience scripts is not a recommended pick, especially for the production environment. The reason Convenience scripts are not recommended :

  1. The convenience scripts mostly install packages without request for confirmation.
  2. Also, nosotros demand 'root' or 'sudo' privileges to run the convenience scripts.
  3. Convenience scripts do not permit the states to customize whatsoever installation.
  4. Information technology, by default, installs the latest version of Docker, and nosotros have no option to specify a version of our pick.

Nosotros can detect the convenience scripts for installing border and testing versions of Docker Engine - Community at get.docker.com  and test.docker.com , respectively. We can utilise these scripts for installing Docker in a non-interactive manner in the evolution environment.

The command to run the convenience script is as follows:

          $ curl -fsSL https://get.docker.com -o become-docker.sh $ sh go-docker.sh                  

Annotation:

  1. Nosotros should non apply convenience scripts on the host machine on which the Docker is installed using other methods.

  2. We should always verify the downloaded convenience scripts before running them on the local machine.

How to install Docker on other Linux versions?

We have seen the Docker installation on the Ubuntu version of Linux. In this section, let us briefly discuss the Docker installation on other Linux versions.

One thing to continue in listen is that irrespective of the Linux distributions, we always need 64-chip installations and kernel version with 3.ten or newer. 4

Docker runs on:

  • Ubuntu
    • Xenial 16.04 LTS
    • Wily 15.10
    • Trusty fourteen.04 LTS
    • Precise 12.04 LTS
  • Debian
    • testing stretch
    • Debian 8.0 Jessie
    • Debian 7.0 Wheezy (with backports enabled)

The steps to install Docker on the Debian Linux version are basically the aforementioned as described above. Just if we are installing docker on Debian distribution, and then kickoff, we need to enable the backports.

The steps to enable backports on Debian Wheezy are as follows:

  1. Log in to the Linux terminal with root/sudo privileges
  2. Navigate to and open "/etc/apt/sources.list.d/backports.listing" . (Create the file if not already exists)
  3. Remove existing entries.
  4. Now add an entry for backports:
          deb http://http.debian.internet/debian wheezy-backports main                  
  1. Now update the packages using the following command:
          apt - get  update  -y                  

One time the above steps are completed, proceed with the installation of Docker.

How to Install Docker on Windows?

Docker provides a community version for Microsoft windows in the form of Docker Desktop.

We tin can install Docker Desktop on Windows 10 Enterprise, Pro, and Educational activity. In improver, we can install Docker on Windows 10 Abode. 1 can download it from here . This link opens up the following screen. 8-Install Docker - Get Docker.png

When " Become Docker " is clicked, the installer " Docker Desktop Installer.exe " is downloaded.

Before we proceed with the installation, let us discuss the system requirements/ prerequisites of the installation.

Prerequisites for installing Docker on Windows

The Windows organization on which Docker Desktop is to be installed should fulfill the post-obit prerequisites.

  1. Windows 10 should be a 64-bit auto with one of the versions: Pro, Enterprise, or Educational activity. The build should exist 16299 or later.
  2. Windows features, namely, Hyper-Five and Containers, should be enabled.
  3. For the successful running of Customer Hyper-V on Windows 10, the fulfillment of the following hardware prerequisites should happen:
    • System RAM should be at least 4GB.
    • The processor (64 chip) should acceptSecond Level Address Translation (SLAT)
    • Using BIOS settings, enable BIOS-level hardware virtualization support.

One time these requirements are fulfilled, nosotros tin can go along with the Docker Desktop installation on Windows.

How to install Docker Desktop on Windows?

I should follow the sequence of steps below to install Docker Desktop on Windows.

  1. Double Click the " Docker Desktop Installer.exe " to begin the installation.

  2. The Docker Desktop installation begins past first downloading the files, and the installation begins equally shown in the below screenshot. 9-Install Docker.png

The to a higher place screenshot shows the installation in progress. Once all the packed files are installed, it will prompt the user to check/uncheck the configuration.

  1. During the installation, the installer prompts united states to enable Hyper-v Windows features. 10-Install Docker - Configure Docker Engine.png

Here we should ensure that all Hyper-five Windows features are enabled, and appropriate components are installed.

One time the configuration dialog box is checked, click " Ok " to proceed with the installation.

  1. In one case installation completes, the user is prompted to restart the machine. 11-Docker Installation Complete.png

We can click " Shut and restart " to restart the machine to complete the installation.

Once the Docker Desktop installation is successful, information technology does not start immediately. Instead, nosotros can outset Docker Desktop by clicking the related Icon from programs or clicking on the Docker Desktop shortcut. Once this is done, the following screen appears. 12-Docker Install working.png

The above screenshot shows the 'Settings screen for the Docker Desktop'. Now that the Docker Desktop is installed successfully and running, we can admission information technology from any terminal window.

How to uninstall Docker Desktop on Windows?

We follow the beneath steps to uninstall Docker Desktop on Windows:

  1. First, click the Windows Start menu, and select Settings > Apps > Apps & features.
  2. Now select/ choose Docker Desktop from theApps & features listing and then click Uninstall.
  3. ClickUninstall to confirm your selection.

Note: As a event of Docker Desktop uninstallation, the Docker containers and images local to the machine are destroyed and as well remove the files generated by the application.

How to Install Docker on macOS?

Docker can be installed on macOS either using the HomeBrew parcel installer or downloading the package direct from the docker site. In this article, we will cover the details of how we can install the Docker on a macOS motorcar using the HomeBrew packet:

Run the following command to install Docker using HomeBrew:

          brew cask install docker                  

One time Docker will be successfully installed, it will show a success message as shown in the following paradigm: 13-installation.jpg

Y'all can likewise validate the successful installation of Docker on macOS by checking the details in Docker Desktop, as shown beneath: 14-Validate Successful Installation of Docker.jpg

Once the Docker is running, y'all tin use information technology for pulling any of the Docker images and spinning containers.

How to uninstall Docker on macOS?

Y'all can run the following command to uninstall Docker from a Mac machine:

          brew cask uninstall docker                  

This will remove all the components from the machine.

Note: The Docker images will not remove from the auto.

Cardinal Takeaways:

  • Docker supports near all modern operating systems, and we can install using diverse package managers provided by the operating systems.
  • On Windows and macOS, Docker provides a desktop version as well that nosotros can use to enable various settings and configurations for the Docker.