1. Home
Docker

Understanding Docker: A Comprehensive Overview

Discover comprehensive Docker tutorials designed for all skill levels. Learn containerization, deployment, and best practices to enhance your development workflow.

  • 11
  • 4
right-top-arrow
2

How to Install Docker on Windows? A Complete Guide to Docker Installation on Windows

Updated on 29/08/2024453 Views

Introduction

Think of an application where you can bundle up everything you need, including all the dependencies, into a single distribution. This is the power of Docker! Docker is a platform that uses a technology known as containerization to facilitate software development, testing, and deployment. This blog discusses how to install Docker on Windows.

Shipping container analogy for Docker containers

Source: Bernhard Wenzel

At its core, Docker operates on three key concepts:

  • Containers: Containers can be thought of as a set of boxes that contain your application’s code, runtime, system libraries, and configuration.
  • Images: These are blueprints that specify the exact content and structure of a container. They are used to generate multiple running containers that are exact replicas of each other.
  • Registries: Registries can be viewed as enormous databases that contain and distribute pre-created Docker images. Docker Hub is a public registry service by Docker that offers a rich source of images for different applications, databases, and development tools.

 Docker hub website

Source: Docker

Two Ways to Docker on Windows

Docker offers two main installation methods for Windows users:

  • Docker Desktop: This is a convenient tool that offers a GUI for working with Docker containers and images. It is suitable for novices and programmers who prefer a graphical environment.
  • WSL 2 (Windows Subsystem for Linux 2): This option enables you to execute a complete Linux system on top of Windows. It is then possible to install Docker within the WSL 2 environment for a more traditional Linux container experience.

System Requirements and Pre-requisites

Let’s make sure your Windows system is up to the task of unleashing the potential of Docker containers. Here is a rundown of Docker setup for Windows:

Hardware Requirements

  • 64-bit Processor: Docker can only be installed on Windows 10 and 11 operating systems that have a 64-bit processor architecture. This is because 64-bit processors can support more memory, which is essential when running multiple containers.
  • Minimum 4 GB RAM: 4 GB RAM is the minimum requirement, but more RAM will be helpful, particularly when working with resource-intensive applications within Docker containers.

Software Requirements

  • Windows 10 (64-bit) Version 1903 or Higher: Docker Desktop officially supports Windows 10 versions starting from 1903 (May 2019 Update) and later.
  • Windows 11 (64-bit): Docker Desktop also works well on Windows 11 machines.
  • Administrator Privileges: Docker Desktop installation involves system configuration changes that require administrator permissions.

WSL 2 (Optional)

Docker Desktop can be run on Windows directly, but some users may prefer using WSL 2. WSL 2 enables you to run the Linux kernel on your Windows device and provides a more Linux-like environment for power users.

Setting up Docker Desktop on Windows

This section will show you how to install Docker on Windows using the recommended approach for Windows users. Docker Desktop for Windows offers a graphical dashboard and makes using Docker on Windows easier.

A. Downloading the Installer

First, go to the official Docker website and download the Docker Desktop installer.

Docker Desktop download page on docker.com

Source: Docker

B. Installation Process

Here is a step-by-step guide:

  1. Download the Installer: Visit the Docker website and click Download Docker Desktop for Windows button. The downloaded file will usually be called “Docker Desktop Installer.exe”.
  1. Run the Installer: Run the installer file that you downloaded by double-clicking it. It is possible to see the User Account Control (UAC) window that asks for permission to run the installer. Click "Yes" to proceed.
  1. License Agreement: The first screen you will see is the Docker license agreement. Read the terms and conditions and click the checkbox accept the license agreement. Then click “Next”.
  1. Installation Options: The next screen allows you to select the components to install. All options are selected by default: Docker engine, components, and Kubernetes.
  1. Installation Location: The installer will prompt a default location to install Docker Desktop. You can leave this default location or click “Browse” to select a different location on your drive.
  1. Shortcut Creation: The next screen gives you the option of creating shortcuts for Docker Desktop on your Start menu and desktop. You can adjust these options depending on your preference.
  1. Start Docker Desktop after Installation: The last radio button allows you to select whether the Docker Desktop should be launched immediately after the installation is complete. This option should be selected for smooth functioning.
  1. Initiate Installation: After you have gone through all the choices, click on ‘Install’ to start the installation process. The application will be download and installed on your system. This may require a few minutes, depending on your internet connection.
  1. Installation Complete: Once the installation is complete, you will be presented with a confirmation window. Click “Finish” to complete the installation process and exit the installer. Docker Desktop for Windows will be launched in the background as a service. It can be found in your system tray or by searching for “Docker Desktop” in the Start menu.

C. Post-Installation Configuration

Once the installation is complete, Docker Desktop may need to access specific system resources to work efficiently. Here is how to enable resource sharing:

  1. Access Docker Desktop Settings: Click the Docker icon in the Windows system tray (typically near the clock) and select Settings.

Docker Desktop system tray icon with right-click menu showcasing settings

Source: GitHub

  1. Navigate to Resources: In the settings window of Docker Desktop, select the “Resources” section.

Docker Desktop Settings window with the Resources tab highlighted

Source: Docker

  1. Enable CPU and Memory Sharing: Ensure there are sufficient CPUs and memory assigned to Docker. The values suggested above will vary depending on the hardware and the type of applications that are being run.

Docker Desktop Resources settings with CPU and Memory allocation sliders

Source: StackOverflow

  1. Configure Network Sharing: Docker containers need network connectivity to reach the outside world. Docker Desktop provides a virtual network for containers by default. The “Resources” section in the “Advanced” tab provides additional options for configuring the Docker network for experienced users.

Docker Commands for Common Tasks

Commands are used to interact with the system in Docker. Here are a few essential commands to get you started:

  • docker ps: This command shows all running containers.

Bash

$ docker ps

CONTAINER ID  IMAGE        COMMAND             STATUS    PORTS         NAMES

3e4c7ba9b84b  ubuntu:latest  /bin/bash            Up       5432/tcp     

my-ubuntu-container

  • docker run: This command is used to launch a new container from a particular image. For example, the following command launches a container based on the "ubuntu:latest” image and gives it the name “my-ubuntu-container”:

Bash

$ docker run -it ubuntu:latest bash

The -it flags mentioned above are used to create an interactive terminal within the container. These are some of the commands that you can try to get a feel for how Docker works.

D. Troubleshooting Common Issues

If you see errors during installation regarding Hyper-V, this could be due to interference with the Docker Desktop. Here is how to check and potentially resolve the issue:

  1. Open the Windows search bar: Type Turn Windows Features on or off and run the program.

Windows Search bar with the query Turn Windows Features on or off

Source: GitHub

  1. Uncheck Hyper-V: Select the “Hyper-V” option and click on the corresponding box to remove the checkmark. Click “OK” to save the changes.

HyperV checkbox highlighted in Turn Windows Features on or off the window

Source: Super User

  1. Reboot your computer for the changes to be implemented. Try to reinstall the Docker Desktop after deactivating Hyper-V.

Checking WSL 2 Compatibility

Docker Desktop can use WSL 2 for additional capabilities. Here is how to verify WSL 2 compatibility:

  1. Open PowerShell: Open the Windows search bar, type PowerShell, and run it as an administrator.
  2. Run the Compatibility Check: Enter the following command and press Enter:

Powershell

wsl –check

The result will show whether your system supports the requirements for WSL 2. If they are, you can continue with the process of enabling WSL 2.

Enabling WSL 2

Enabling WSL 2 is a multi-step process. Refer to the official Microsoft documentation for detailed instructions: https://learn.microsoft.com/en-us/windows/wsl/install

Wrapping Up

You have just opened a world of opportunities for development, testing, and deployment by installing Docker on Windows. Docker enables you to accelerate development, improve collaboration, and automate deployments. Begin using these resources and get started with Docker on Windows and the world of containerization!

FAQs

1. Can you install Docker on Windows?

It is possible to install Docker on Windows. Docker offers Docker Desktop for Windows, which is a tool that makes it easier to install and use Docker on Windows OSs. Docker Desktop for Windows 10, Windows 11, and other Windows servers is supported on these OSs.

2. How Docker can run on Windows?

Docker on Windows is implemented through Docker Desktop, which uses a Hyper-V or WSL 2 VM. This VM establishes a Linux platform that allows Docker containers to execute in a native environment for compatibility and performance purposes.

3. How do I install Docker as a service on Windows?

Docker Desktop automatically installs Docker as a service on Windows. Docker Desktop also configures the Docker Engine as a background service that runs when your system boots. It can be controlled using the Windows Services management snap-in or through the Docker Desktop user interface.

4. How do I know if Docker is installed on Windows?

To check if Docker is installed on Windows, open Command Prompt or PowerShell and run the below-mentioned command:

sh

docker-version

If Docker is installed, the command will return the version of Docker. Alternatively, you can also open Docker Desktop and check its status in the taskbar.

5. What is Docker used for?

Docker is used for building, running, and orchestrating containers. Containers are isolated, virtual, and consistent platforms that execute applications. Docker is extensively employed for microservices, CI/CD, development environments, and general deployment across various platforms.

6. Can I run Docker on Windows without Docker desktop?

It is possible to use Docker on Windows without Docker Desktop by using Docker with WSL 2 or other virtualization tools, such as VirtualBox with Docker Machine. But Docker Desktop offers a more seamless and interactive experience.

7. How to install Docker step by step?

Here is a step-by-step guide to installing Docker Desktop on Windows:

  • Download Docker Desktop: Go to the Docker Hub website and download the Docker Desktop installer.
  • Run the Installer: Launch the downloaded installer and proceed with the installation steps.
  • Enable Required Features: Make sure that Hyper-V and WSL 2 features are installed during the installation process.
  • Complete Installation: After the installation is finished, Docker Desktop will launch.
  • Verify Installation: To verify the installation, open Command Prompt or PowerShell and type docker-version.

8. How to install Docker in cmd?

If you want to install Docker using Command Prompt (cmd), you need to use the Docker Desktop installer. The installation process itself is graphical but you can invoke the installer from the command line. Here is how:

Download Docker Desktop Installer: Go to the Docker website and download the installer for Docker Desktop.

Run Installer from Command Prompt:

sh

start docker-desktop-installer.exe

Follow Installation Prompts: Finish the installation through the graphical interface that will be displayed.

9. How to use Docker step by step?

Here are the basic steps to using Docker:

Open Docker Desktop: Make sure the Docker Desktop is up and running.

Pull an Image: Use the command:

sh

docker pull <image_name>

For example, to pull the nginx image:

sh

docker pull nginx

Run a Container: Start a container using: docker run -it –name <container_name> <image_name>

sh

docker run -d -p 80:80 nginx

List Running Containers: Check running containers with docker ps -a.

sh

docker ps

Stop a Container: Stopping a running container requires:

sh

docker stop <container_id>

Remove a Container: Delete a stopped container with:

sh

docker rm <container_id>

If you stick to these steps, you can start using Docker to streamline your development and deployment workflows on Windows. Docker is a leading platform for containerizing applications and should be considered an indispensable part of any development environment.

Mukesh Kumar

Mukesh Kumar

Working with upGrad as a Senior Engineering Manager with more than 10+ years of experience in Software Development and Product Management.

Talk to Career Expert
form image
+91
*
By clicking, I accept theT&Cand
Privacy Policy
image
Join 10M+ Learners & Transform Your Career
Learn on a personalised AI-powered platform that offers best-in-class content, live sessions & mentorship from leading industry experts.
right-top-arrowleft-top-arrow

upGrad Learner Support

Talk to our experts. We’re available 24/7.

text

Indian Nationals

1800 210 2020

text

Foreign Nationals

+918045604032

Disclaimer

upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enr...