Installing Docker on Different Platforms

Tutorial 2 of 5

Tutorial: Installing Docker on Different Platforms

1. Introduction

In this tutorial, we will walk you through the installation process of Docker on different platforms including Windows, Mac, and Linux. Docker is an open-source platform that automates the deployment, scaling, and management of applications. It encapsulates software into containers, making it more flexible and portable.

By the end of this tutorial, you will learn how to:

  • Install Docker on Windows, Mac, and Linux.
  • Verify the Docker installation.

Prerequisites: Basic knowledge of command-line interfaces is beneficial but not required.

2. Step-by-Step Guide

Installation on Windows

Step 1: Visit Docker Hub at https://hub.docker.com/editions/community/docker-ce-desktop-windows/ and download the Docker Desktop for Windows installer.

Step 2: Run the installer and follow the prompts.

Step 3: After installation, start Docker Desktop.

To verify the installation, open a command prompt and enter:

docker --version

You should see the Docker version in the output.

Installation on Mac

Step 1: Visit Docker Hub at https://hub.docker.com/editions/community/docker-ce-desktop-mac/ and download the Docker Desktop for Mac installer.

Step 2: Open the installer and drag the Docker.app to your Applications folder.

Step 3: Start Docker Desktop.

To verify the installation, open a terminal window and enter:

docker --version

You should see the Docker version in the output.

Installation on Linux (Ubuntu)

Step 1: Update your existing list of packages:

sudo apt update

Step 2: Install a few prerequisite packages which let apt use packages over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step 3: Add the GPG key for the official Docker repository to your system:

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

Step 4: Add the Docker repository to APT sources:

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

Step 5: Finally, install Docker:

sudo apt update
sudo apt install docker-ce

To verify the installation, enter:

docker --version

You should see the Docker version in the output.

3. Code Examples

Here are some examples of expected output when verifying Docker installation:

  • For Windows and Mac:
docker --version
Docker version 20.10.2, build 2291f61
  • For Linux (Ubuntu):
docker --version
Docker version 20.10.2, build 20.10.2-0ubuntu1~20.04.2

In these examples, 20.10.2 is the installed Docker version number.

4. Summary

In this tutorial, we've walked you through the process of installing Docker on Windows, Mac, and Linux. Now you should be able to install Docker on your preferred operating system and verify the installation.

For further learning, we recommend exploring more about Docker commands and how to work with Docker containers.

5. Practice Exercises

Here are some exercises to practice:

  1. Install Docker on your machine and verify the installation.
  2. Pull a Docker image from Docker Hub and run it.
  3. List all Docker images on your machine.

Solutions:

  1. Follow the steps in the tutorial to install Docker and verify the installation.
  2. To pull a Docker image (for example, the hello-world image) and run it, use the following command:
docker run hello-world
  1. To list all Docker images on your machine, use the following command:
docker images

Remember, practice is the key to learning any new skill. Happy Dockering!