Рассмотрим установку Docker Desktop for Windows — это Community-версия Docker для систем Microsoft Windows.
Системные требования
- Windows 10 64-bit: Pro, Enterprise, Education (Build 16299 или выше).
Для успешного запуска Client Hyper-V в Windows 10 требуются следующие предварительные требования к оборудованию:
- 64 bit процессор c поддержкой Second Level Address Translation (SLAT).
- 4GB системной памяти.
- Поддержка аппаратной виртуализации на уровне BIOS должна быть включена в настройках BIOS.
Подготовка
Включаем функции Hyper-V Containers Window. Для этого переходим в панель управления — установка и удаление программ — включение или отключение компонентов Windows. Активируем пункт Hyper-V, который включает Hyper-V Managment Tools, Hyper-V Platform.
Также это можно выполнить через powershell или dism (все команды необходимо выполнять с правами администратора).
Powershell:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
DISM:
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
Установка
Скачиваем установщик Docker (Docker Desktop Installer) с Docker Hub.
Установка Docker Desktop включает Docker Engine, Docker CLI client, Docker Compose, Notary, Kubernetes и Credential Helper. Контейнеры и образы, созданные с помощью Docker Desktop, используются всеми учетными записями пользователей на компьютерах, на которых он установлен. Это связано с тем, что все учетные записи Windows используют одну и ту же виртуальную машину для создания и запуска контейнеров. При использовании Docker Desktop WSL 2 невозможно обмениваться контейнерами и образами между учетными записями пользователей.
Запускаем установщик Docker Desktop Installer.exe и ожидаем пока он скачает все необходимые компоненты.
После установки система потребует перезагрузки. Перезагружаемся и входим в систему.
После входа может возникнут запрос на установку дополнительного компонента WSL2. Переходим по ссылке и скачиваем необходимый пакет с официального сайта Microsoft.
После скачивания выполняем установку WSL2, после которой снова потребуется перезагрузка.
Настройка и запуск приложения
Входим в систему и ждем запуска всех служб Docker. Когда все службы будут запущены, мы увидим в трее классический значок Docker — это значит что служба установлена и запущена. Далее можно запустить приложение Docker desktop. Далее можно изменить настройки Docker при необходимости:
Рисунок 1 — Изменение параметров Docker desktop
Далее управление Docker выполняется через Powershell. Проверяем версию и выполняем тестовый запуск контейнера:
Рисунок 2 — Проверка версии Docker
После выполнения всех этих действий, Docker готов к использованию.
Нужна помощь? Настройки docker/docker swarm/docker compose мы осуществляем в рамках услуги DevOps-аутсорсинг.
1,600 words, 8-minute read
Docker can be installed on Linux, mac OS, or Windows.
Requirements and installation instructions can be found on the Docker Docs help pages.
Install Docker on Linux #
Docker Desktop for Linux can be downloaded from Docker Hub. The installer includes the Docker server, CLI, Docker Compose, Docker Swarm, and Kubernetes.
Alternatively, the Docker command-line tool is available in official Linux repositories although these are often older editions. The latest edition is supported on recent 64-bit editions of popular Linux distros:
- Ubuntu (and derivatives such as Mint)
- CentOS
- Debian
- Fedora
Static binaries are available for other distros, although Googling “install Docker on [your OS]” may provide easier instructions, e.g. “install Docker on a Raspberry Pi”.
Follow the Docker documentation for your distro. For example, Docker for Ubuntu is installed with the following commands:
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
To run Docker commands as a non-root user (without sudo
), create and add yourself to a docker
group:
sudo groupadd docker
sudo usermod -aG docker $USER
Then reboot to apply all changes.
Install Docker on macOS #
Docker Desktop for macOS Sierra 10.13 and above can be downloaded from Docker Hub. The package includes the Docker server, CLI, Docker Compose, Docker Swarm, and Kubernetes.
Two editions are available: stable and edge with experimental features. The stable version is best for most developers.
Double-click Docker.dmg
to open the installer, then drag the Docker icon to the Applications folder. Double-click Docker.app in that folder to launch Docker.
After completion, the whale icon in the status bar indicates Docker is running and commands can be entered in the terminal.
Install Docker on Windows #
Docker Desktop for Windows requires either WSL2 or Hyper-V.
Windows Subsystem for Linux (WSL) 2 #
WSL allows you to run full Linux environments directly on Windows 10 or Windows 11.
IMPORTANT!
You can not install the Linux edition of Docker within a WSL-powered Linux distro. You must install Docker Desktop for Windows which allows Docker commands to be run in all Windows and Linux terminals.
WSL2 is the recommended default option for Docker on Windows. It is faster than Hyper-V and available in all editions of Windows 11 and Windows 10 from the May 2020 update (version 2004, OS build 19041).
To install WSL2:
-
Enable hardware virtualization support in your BIOS.
This will be active on most devices, but check by rebooting and accessing your PC’s BIOS panels – typically by hitting DEL, F2, or F10 as your system starts. Look for Virtualization Technology, VTx or similar options. Ensure they are enabled, save, and reboot.
WARNING! Be careful when changing BIOS settings – one wrong move could trash your PC.
-
Enable the Virtual Machine Platform and Windows Subsystem for Linux options in the Turn Windows features on or off panel:
This can be accessed by hitting the Start button and typing the panel name or from Programs and Features in the classic Control Panel.
-
Reboot, then enter the following command in a Windows Powershell or
cmd
prompt to set WSL2 as the default:wsl --set-default-version 2
-
Download and install your preferred distro by searching for “Linux” in the Microsoft Store app. Ubuntu is a good choice.
-
To complete the installation, launch your distro by clicking its Store’s Launch button or choosing its icon from the Start menu.
You may be prompted to install a kernel update – follow the instructions and launch the distro again.
-
Enter a Linux username and password. These are separate from your Windows credentials although choosing the same ones can be practical.
-
Ensure your distro is up-to-date. For example, on an Ubuntu bash prompt enter:
sudo apt update && sudo apt upgrade
You can now install Docker Desktop (see below). For the best performance and stability, store development files in your Linux file system and run Docker from your Linux terminal.
More information about installing and using WSL2:
- Windows Subsystem for Linux 2: The Complete Guide, and
- optionally, Windows Terminal: The Complete Guide.
Hyper-V #
The Microsoft Hyper-V hypervisor is provided free with Windows 10 and 11 Professional and Enterprise. (Windows Home users must use WSL2.)
To install Hyper-V:
-
Enable hardware virtualization support in your BIOS.
This will be active on most devices, but check by rebooting and accessing your PC’s BIOS panels – typically by hitting DEL, F2, or F10 as your system starts. Look for Virtualization Technology, VTx or similar options. Ensure they are enabled, save, and reboot.
WARNING! Be careful when changing BIOS settings – one wrong move could trash your PC.
-
Enable the Hyper-V option in the Turn Windows features on or off panel then reboot.
This can be accessed by hitting the Start button and typing the panel name or from Programs and Features in the classic Control Panel.
You can now install Docker Desktop.
Install Docker Desktop for Windows #
Docker Desktop for Windows 10 and 11 can be downloaded from Docker Hub. The installer includes the Docker server, CLI, Docker Compose, Docker Swarm, and Kubernetes.
Two editions are available: stable and edge with experimental features. The stable version is best for most developers.
Double-click Docker Desktop Installer.exe
to start the installation process. After completion and launch, the whale icon in the notification area of the task bar indicates Docker is running and ready to accept commands in the Windows Powershell/cmd
terminal (and Linux if using WSL2).
Docker Engine Settings #
Docker uses WSL2 as the default engine when available. You will be prompted to confirm this choice during installation and after WSL2 is installed.
Alternatively, WSL2 can be enabled by checking Use the WSL 2 based engine in the General tab of Settings accessed from the Docker task bar icon. Unchecking the option reverts to Hyper-V.
When using WSL2, at least one Linux distro must be enabled – the default is chosen. You can also permit Docker commands in other distros by accessing the WSL integration panel in the Resources section of the Docker Settings:
When using Hyper-V, Docker must be granted access to the Windows file system. Select the drives it is permitted to use by accessing the File Sharing panel in the Resources section of the Docker Settings:
(This option was named Shared Drives in previous editions of Docker Desktop.)
Test your Docker installation #
Check Docker has successfully installed by entering the following command in your terminal:
docker version
A response similar to the following is displayed:
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: abcdef0
Built: Mon Jun 22 15:45:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
...etc...
Ensure Docker Compose is working by entering:
docker-compose version
To receive something like:
docker-compose version 1.27.2, build 8d51620a
docker-py version: 4.3.1
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.1c 10 Sep 2019
Optionally, try entering:
docker run hello-world
to verify Docker can pull an image from Docker Hub and start containers as expected…
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows your installation appears to be working correctly.
Key points #
What you’ve learned in this chapter:
- How to install and configure Docker on your Linux, macOS, or Windows system.
- How to install Docker Compose.
- How to test the Docker installation.
The following chapters demonstrate how to use Docker during development…
…but to continue reading, you need to buy the book.
Do you want an easy-to-follow course which demonstrates how to use Docker and create practical web development environments on your Windows, macOS, or Linux PC?
Buy the «Docker for Web Developers» book & video course…
-
full course
$99 $50 £43 / €49
buy all
-
ebooks only
$30 $15 £13 / €15
buy books
-
videos only
$80 $40 £34 / €40
buy videos
plus your country’s sales tax where applicable
Pre-requisites: Windows OS, Docker
Before understanding the concept of Docker, let’s first discuss the concept of Hypervisors. So in an IT Company, or any cooperate, there is a development team, a testing team, and an operation team for developing the application, testing it, and deploying it. Now suppose the developers are working on a different OS, for example, let’s say macOS, and they used some dependencies or libraries as per the language they are using, so they just won’t hand the software to the testing team, but also the libraries, but now, the application didn’t run o the tester’s machine, but it worked on the developer’s machine, maybe because the tester’s machine has different OS features than the developer’s one, so now, devs have to send the OS, but that is not practically possible, as one can’t just copy the C drive and hand it over, that’s where the concept of Hypervisors comes into the picture, think of this as a virtual machine or Wim-ware, so you have the physical hardware, you host an OS on it, and the OS can now host another OS also called Guest OS, and this guest OS can be packed and send to the testing team.
But the problem here is, for every application, one needs a different OS, this will result in a waste of resources as multiple OSs will be running. So for this problem, we have the concept of Containers, the difference between Hypervisors and containers is that we don’t need multiple OS for every application, multiple applications can share the same OS kernel, great isn’t it? So instead of installing HYPERVISOR, we will be installing Docker.
What is Docker?
Docker is an open-source platform where we run our applications in the form of containers. Docker containers are very light in weight and contain all the dependencies and configurations so we can run them across different computing environments. Developers can package all the dependencies of the application in the form of images it can be portable easily or shared easily with other developers without worrying about the underlying OS.
Requirements
- Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2.
- Windows 10 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2.
- 4GB RAM or Higher.
- Hyper V feature must be enabled in Windows.
Specifications
- RAM: The minimal amount of Memory needed to run containers smoothly is 4GB, however, if a program has more complicated functions, it will need more than 6 GB RAM.
- Storage: For running the containers and installation of docker the minimum space required is 25GB. If you want to store the container images and data then we need at least more than 35 GB to 40 GB.
- Network: To download, push and pull the images we need active internet then only we can maintain the container images with the help of docker.
- CPU: At least a 64-bit processor is required for docker.
Docker can be run on a laptop with 4 GB of Memory, a 64-bit processor, and 25 GB of storage. It might change based on our use cases.
Step-By-Step Docker Installation On Windows
Follow the below steps to install and configure Docker on Windows:
Step 1: For installation of Docker, go to your favorite browser(chrome will be used here, but it can be done by using any browser). In the search bar, type Docker download. And click on the first link that appears.
Step 2: After clicking the link, choose your OS, be it Windows, MAC, or Linux for installation.
Step 3: The download will start, and based on your internet speed, it will take some time to do so. To know more about docker desktop installation visit Docker Desktop.
Start Docker Desktop Tool
Step 1: After installation, it will look something like this in Windows:
- Open the Docker Desktop.
- Accept the Docker Subscription Service Agreement window. and click On continue. Docker Desktop will start after we accept the terms and conditions.
Step 2: After clicking Ok the installation will start.
Step 3: After installation, it will show something like the below:
Step 3: After installation, we need to restart our PC and install WSL 2, which stands for Windows Setup for LINUX. It is a compatibility layer for running Linux binary executables natively on Windows 10. Please follow the next few instructions carefully. After restarting, the following dialog box will appear, then click on the Stop Docker button there.
Step 4: After clicking, we need to enable the Hyper-V, for that we will restart the PC and go to BIOS setup, Settings>Update and Security>Recovery>Advanced Setup>Device Configuration. After that, if the option Enable Turbo Boost on DC. is unmarked, mark it, after it, save, and exit.
Step 5: Afterward, in the last step, go to Control Panel> Turn Windows Features on and off. Then for activating Hyper-V, mark the Hyper-V and Windows Hypervisor Platform.
At this point, you have successfully installed and configured Docker on your Windows machine.
How To Install From The Command Line?
To install the Docker desktop, follow the procedures listed below.
Step 1: Run the following command in the Command prompt.
start /w "" "Docker Desktop Installer.exe" install
Step 2: Add user account into docker user groups.
net localgroup docker-users <users>/add
Verification
Verify the docker installation and versions,
1. Run the following command in the command prompt to check the docker version.
docker --version
2. After that we will receive a Beta invitation email When you start docker for the first time.
How To Install Docker On Windows 10?
You must perform the following steps in order to install Docker on Windows 10:
Step 1: In this step, we must assure that our Windows can support Docker the minimum requirement is Docker requires 64-bit Windows 10 Pro.
Step 2: You can download the docker by using this link “https://www.docker.com/products/docker-desktop”.
Step 3: Once the installation is finished go to the start menu and open Docker Desktop. Enable Hyper-V and Windows Subsystem for Linux features after enabling Docker Desktop will automatically restart. After restarting you can open the Docker Desktop and start using it.
Step 4: To test whether the Docker Desktop is installed or not open the command prompt or PowerShell window and run try to pull the sample image for example Nginx if the image is pulled then the Docker installation in Windows was completed successfully completed.
How To Install Docker On Windows 11?
First, make sure that your Windows matches Docker’s requirement Docker requires 64-bit Windows 11 Pro, and the rest all the steps are the same as Windows 10.
How To Update The Docker In Windows?
By following the steps mentioned below we can update our Docker:
Step 1: Open the Docker Desktop from the start menu.
Step 2: Click on the settings and click on the “resource” tab there we can find an option called “Check for Updates.”Docker Desktop will check for any available updates.
Step 3: If any update is available Docker will show us like “Download and Install” Directly click on it Docker Desktop will automatically download it after completion of installation you can the Docker version by using the following command in the command prompt or PowerShell window.
docker version
Advantages of Docker In Windows
- Docker for Windows allows developers to their applications easily on any Windows.
- Docker can be installed very easily on Windows.
- Docker containers can be moved in between Windows and Linux without changing the Source code.
- The application is isolated from the underlying OS which makes it more secure.
Uninstall Docker Desktop Tool
To uninstall the Docker Desktop follow the steps mentioned below.
- Find “Add or Remove Programs” in the start menu and choose it.
- Click Docker Desktop when you see Docker in the list of installed programs.
- When you click on uninstall in Docker Desktop, be sure to follow the steps that appear.
- After the uninstallation is complete, restart the computer.
How To Install And Enable WSL 2 On Windows
Before installing docker by using WSL 2 make sure your Windows is supported for that and then install and enable WSL2 on your laptop.
Step 1:Enter the following command as an administrator to enable the Windows Subsystem for Linux feature.
dism.exe /online /enable-feature /featurename :Microsoft-Windows-Subsystem-Linux /all /norestart
Step 2: In this step, you need to enable the virtual machine platform feature to enable it to run the following command in Powershell as an administrator
dism.exe /online /enable-feature /featurename :VirtualMachinePlatform /all /norestart
Step 3: After running the above command you need to restart your computer by this the virtual machine platform feature will be enabled.
Step 4: Know download and install WSL 2 Linux kernel updated package from the official website of Microsoft
Step 5: Make WSL 2 the standard version. Run the following command when logged in as an administrator in Windows PowerShell.Install a Linux distribution by using the Microsoft Store. You can pick from a variety of Linux distributions, including Kali Linux, Debian, and Ubuntu.
wsl --set-default-version 2
After completing the above steps we can use execute Linux commands on your windows using WSL 2.
How To Install Docker With WSL 2 Backend On Windows?
Utilizing dynamic memory allocation will help the WSL 2 backend consume resources more efficiently. which enables us to launch Docker very quickly and improve Docker’s speed. To make this happen please follow the steps mentioned below.
Step 1: Install and enable WSL 2 on Windows by following the steps outlined in the previous answers. And install Docker Desktop as mentioned above for Windows.
Step 2: Once the Docker Desktop installation is completed open the setting in Docker Desktop click on the resources tab and click on WSL 2 integration. Click “Apply & Restart” to apply the changes.
Step 3: Open a terminal in your WSL 2 distribution and use the following command to confirm that Docker is operational after Docker Desktop has restarted.
docker pull ubuntu
If the image is successfully retrieved, WSL 2 has likely been deployed as a backend for Docker. The WSL 2 backend now allows you to use Docker to construct and manage containers on your Windows computer.
Note: The Docker CLI interacts with the Docker daemon running in the Windows Docker Desktop application when you issue Docker commands in your WSL 2 terminal.
Conclusion
In this article, we covered a step-by-step procedure to install docker in Windows 11 and Windows 10. We also covered how to install docker in Windows 10 and 11 with the help of the Command line. Refer to Install in Mac and Ubuntu to know more about installation in different OSs.
For many developers, Docker is the platform for creating and deploying applications in self-sufficient containers. It is an OS-level virtualization platform that helps users build and manage applications without worrying about dependencies and underlying OS.
In this guide, we will see how to install Docker desktop on Windows 10 or Windows 11. We’ll also mention the benefits of Docker on Windows and how you can uninstall it from the Windows environment.
Let’s start with the benefits of Docker on Windows.
Table Of Content
- What are the Benefits of Working with Docker on Windows?
- Install Docker on Windows 10 & 11
- Prerequisites
- Install Docker Desktop on Windows 11
- Start Docker Desktop Tool
- How To Install Docker on Windows 10?
- How to Install Docker From the Command Prompt
- Uninstall the Docker Desktop Tool
- Conclusion
What are the Benefits of Working with Docker on Windows?
Docker on Windows brings a range of benefits to the development process and application deployment, including:
- The simple user interface allows you to view and monitor all Docker containers from one location.
- Docker takes care of allocating the required resources and memory space for the containers.
- Supports HTTP proxy settings
- Docker allows developers to create containerized applications that can run in a Windows environment. This makes it easy to build and test applications on Windows and then deploy them to other platforms without compatibility issues.
- Docker images can be easily moved between development, testing, and production environments, which makes it easier to maintain consistency and reduce the risk of errors or bugs caused by differences between environments
Like all environments, you need the following elements to run Docker containers in a Windows environment:
- Docker Engine: This runs on the host machine to build and run containers.
- Docker Client: This receives the commands from the users, translates them into REST API, and delivers them to the Docker Daemon.
- Docker Daemon: This manages Docker containers
- Docker Compose: This runs multiple container applications.
Now that you know what you need, we’ll explain the installation process of Docker on the Windows operating system.
Before we discuss the installation process, we should go into the details of prerequisites and related information so that you have a solid foundation on installing Docker on Windows 10 & 11, especially if using it with a dedicated server.
Prerequisites
- Windows 10 64-bit or Windows 11 64-bit (version 2004 or higher for Pro edition; version 1909 or higher for Enterprise and Education editions)
- The target machine should have a 64-bit processor with support for Second Level Address Translation (SLAT).
Minimum 4 GB RAM. - BIOS settings and hardware virtualization support must be enabled.
- Support for Windows Hyper-V enabled.
- Support for Older Windows versions
Install Docker Desktop on Windows 11
Let’s start with the process of installing Docker Desktop on Windows 11. The process involves several steps that are detailed below.
- Visit the Docker Desktop For Windows download page and download the Docker Desktop installation file.
Note: The target machine should have a 64-bit processor and 4GB system RAM to run Docker successfully on Windows 10.
- Run the installer and remember to enable the Hyper-V Windows feature on the Configuration page.
- Complete the installation process and restart the computer once the process finishes.
Start Docker Desktop Tool
After completing the installation, you’ll need to start the Docker tool manually. For this, locate or search for “Docker Desktop” in the desktop search bar.
Before you can get started with Docker, you’ll need to go through the onboarding tutorial. This will help you learn how to build a Docker image and run a container.
Once you’ve completed the tutorial, you’ll be up and running with Docker Desktop on Windows. To verify if everything is working correctly, go to the Docker CLI and run the “docker version” command. This will tell you the Docker version installed on your system.
At this point, Docker has been installed on your Windows 11 machine and is ready for running containers and Docker images.
How To Install Docker on Windows 10?
The process of installing Docker on Windows 10 is similar to installing Docker on Windows 11. Let’s see the major steps of the process.
Start by downloading the installer from the official Docker for Windows page.
Once the download finishes, locate the downloaded file and run it.
On the setup page, you must choose the options, such as the Hyper-V and WSL 2 features. Then, click “OK” and follow the instructions of the wizard. Close the wizard when it finishes.
When using Docker, it’s important to know that the administrator account and Docker user accounts are often the same. If you don’t have a Docker user group, you will need to create one and add your user account to it.
Initially, run the admin panel as computer management.
You can add new users to the Docker group by going to the Local Users and Groups and, from there, find Docker user groups.
After you’ve completed all these steps, restart your computer to update and start Docker Desktop on Windows 10.
Once the system comes back online, start Docker Desktop.
It will prompt you to review and accept the Subscription Services Agreement for Docker Desktop. Once you accept and agree to the terms and conditions, the Docker Desktop window will appear, and you’re ready to work!
Remember to go through the Quick Start guide included with Docker Desktop for a better experience.
Resolving the WSL Kernel Version Error
Some Windows 10 systems can show the following error about Docker Desktop requiring a newer version of the WSL kernel.
To resolve this error, launch the Command Prompt and run the following command:
wsl --update
How to Install Docker From the Command Prompt
If you wish, you can install Docker Desktop from the Command Prompt. This is a simple process where you enter a simple command to initiate the installation process. But first, you need to download the Docker Desktop installer from the official site.
Here are the commands you’ll need to run:
If you’re in a terminal window, run the following command:
"Docker Desktop Installer.exe" install
If you’re in the PowerShell, run the following command:
Start-Process '.\win\build\Docker Desktop Installer.exe' -Wait install
Finally, if you’re at the Command Prompt, run the following command:
start /w "" "Docker Desktop Installer.exe" install
When the process finishes, don’t forget to add your user account to the Docker user group, especially if your admin account and user account are not the same. To do that, run this command:
net localgroup docker-users <users>/add
How do I Know if Docker is Installed on my Windows 10/ Windows 11 Machine?
After the installation finishes, it is always a good idea to verify if everything is working as intended. For this, you can try the following ideas:
- If you’re using a Windows terminal, you can use the following command line to launch Docker:
docker-run
- From Powershell, you can verify the Docker version and installation by entering the following command:
docker --version
- You can also check the latest version of the Docker desktop from the Docker option.
- Alternatively, you can check for a web server by running the Docker desktop.
Uninstall the Docker Desktop Tool
There are times when you might want to remove Docker from the Windows machine. Like the installation process, the uninstallation process is straightforward.
1. Go to the Windows Start menu.
2. Choose Settings > Apps > Apps & features.
3. Docker Desktop should be present in the Apps & features list.
4. Click Uninstall.
Conclusion
Docker on Windows is a quick and easy way to run applications in containers on Windows operating systems. Developers can build, package, and deploy applications more efficiently and consistently across different environments using containers. This improved productivity and reduced complexity help organizations save time and money.
Docker on Windows is the perfect way to utilize the features of both Windows and Linux-based containers. However, it is important to note that Docker on Windows does have some limitations and requirements, such as minimum hardware specifications and the use of Windows 10 Professional or Enterprise editions with the Hyper-V feature enabled.
Docker requires a Linux kernel to run Linux Containers. To install Docker on windows, we need to set up a Linux virtual machine to run as a guest in Windows 10 Home.
As a part of our Server Management Services, we help our Customers with Docker related requests regularly.
Let us today discuss the steps involved to install Docker on Windows.
How do Docker installation work In Windows?
As we discussed earlier, Docker requires a Linux kernel to run Linux Containers. Thus we will need to set up a Linux virtual machine to run as a guest in Windows 10 Home for this to work on Windows.
We can perform the Linux VM set up manually using the Docker machine. Docker machine is a CLI tool for installing Docker Engine on virtual hosts.
This Docker Linux VM can either run on the local system or on a remote server. Docker client will use SSH to communicate with Docker Engine. Docker Engine runs on top of the Linux Kernel and helps in building/running containers.
Whenever we create and run images, the actual process will happen within the VM, not on the host (Windows).
Initial Setup to install Docker on Windows
The initial setup involve installing a few additional software. Also, we need to make sure that we are using the latest stable version of Windows. The additional software to be installed includes:
- Install Git Bash for Windows. This will be our primary terminal for running Docker commands.
- Install Chocolatey, a package manager for Windows. It will make the work of installing the rest of the programs easier.
- Install VirtualBox and its extension. Alternatively, after installing Chocolatey, we can simply execute this command inside an elevated PowerShell terminal:
C:\ choco install virtualbox
- To run Docker inside the WSL2 environment, we need to set up WSL2 first.
Docker Engine Setup to install it on Windows
Let us now discuss the steps to install Docker Engine. First, we need to install Docker Machine.
- Install Docker Machine by executing the command inside an elevated PowerShell terminal.
C:\ choco install docker-machine - Using Git Bash terminal, use Docker Machine to install Docker Engine. This will download a Linux image containing the Docker Engine and have it run as a VM using VirtualBox. Simply execute the following command:
$ docker-machine create –driver virtualbox default - Next, we need to configure which ports are exposed when running Docker containers. Doing this will allow us to access our applications via localhost<:port>. To do this, we need to launch Oracle VM VirtualBox from the start menu. Select default VM on the side menu. Next click on Settings > Network > Adapter 1 > Port Forwarding. We should find the ssh forwarding port that is already set up.
- Next, we need to allow Docker to mount volumes located on the hard drive. By default, we can only mount from the C://Users/ directory. To add a different path, simply go to Oracle VM VirtualBox GUI. Select default VM and go to Settings > Shared Folders. Add a new one by clicking the plus symbol. Enter the fields like so. If there’s an option called Permanent, enable it.
- To get rid of the invalid settings error, simply increase Video Memory under the Display tab in the settings option. Video memory is not important in this case, as we will run the VM in headless mode.
- To start the Linux VM, simply execute this command in Git Bash. The Linux VM will launch. Give it some time for the boot process to complete. It should not take more than a minute. We will need to do this every time after the host OS boot:
$ docker-machine start vbox - Next, we need to set up our Docker environment variables. This is to allow the Docker client and Docker Compose to communicate with the Docker Engine running in the Linux VM, default. Let us look at the steps to set up Docker environment variables.
Setup Docker environment variables
We can do this by executing the commands in Git Bash:
# Print out docker machine instance settings
$ docker-machine env default# Set environment variables using Linux 'export' command
$ eval $(docker-machine env default --shell linux)
We need to set the environment variables every time we start a new Git Bash terminal. To avoid this, we can copy eval output and save it in the .bashrc file. It should look something like this:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH="C:\Users\Michael Wanyoike\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"For the DOCKER_CERT_PATH
We need to change the Linux file path to a Windows path format. Also, take note that there is a chance the IP address assigned might be different from the saved one every time we start the default VM.
Docker Tools Setup
Next, we need to install the following tools using PowerShell in admin mode. These tools are packaged inside the Docker for Windows installer. Since the installer refuses to run on Windows 10 Home, we will install these programs individually using Chocolatey:
C:\ choco install docker-cli
C:\ choco install docker-compose
Once the installation process is complete, we can switch back to Git Bash terminal. It is better to execute commands in Linux syntax. Let us execute the following commands to ensure Docker is running:
# Start Docker VM
$ docker-machine start default
# Confirm Docker VM is running
$ docker-machine ls
# Configure Docker Envrionment to use Docker Vm
$ eval $(docker-machine env default --shell linux)
# Confirm Docker is connected. Should output Docker VM specs
$ docker info
# Run hello-world docker image. Should output "Hello from Docker"
$ docker run hello-world
If all the above commands run successfully, it means we have successfully installed Docker.
For hot module reloading to work from a Docker Container in Windows requires the following:
- When using parcel, specify HMR port in the package.json start script:
parcel src/index.html –hmr-port 1235 - In the VM’s Port Forwarding rules, make sure these ports are exposed to the host system:
1234
1235 - inotify does not work on vboxsf filesystems, so file changes can’t be detected. The workaround is to set polling for Chokidar via environment variables in docker-compose.yml. Here’s the full file so that we can see how it’s set:
version: '3' services: dev: image: node:10-jessie-slim volumes: - nodemodules:/usr/src/app/node_modules - ./:/usr/src/app working_dir: /usr/src/app command: npm start ports: - 1234:1234 - 1235:1235 environment: - CHOKIDAR_USEPOLLING=1 volumes: nodemodules: external: true
Now that we have a fully working implementation of Docker on Windows 10 home, let us set it up on WSL2 for those who are interested.
Windows Subsystem for Linux 2
Installing Docker on WSL2 is not as straightforward as it seems. Unfortunately, the latest version of the Docker Engine can’t run on WSL2. However, there’s an older version, docker-ce=17.09.0~ce-0~ubuntu, that is capable of running well in WSL2. Let us see how to access Docker Engine running in the VM we set up earlier from a WSL terminal.
All we have to do is install Docker client and Docker compose. On WSL2 Ubuntu Terminal, execute the following:
- Install Docker using the official instructions:
# Update the apt package list. sudo apt-get update -y # Install Docker's package dependencies. sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ software-properties-common # Download and add Docker's official public PGP key. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # Verify the fingerprint. sudo apt-key fingerprint 0EBFCD88 # Add the `stable` channel's Docker upstream repository. # # If we want to live on the edge, we can change "stable" below to "test" or # "nightly". I highly recommend sticking with stable! sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" # Update the apt package list (for the new apt repo). sudo apt-get update -y # Install the latest version of Docker CE. sudo apt-get install -y docker-ce # Allow the user to access the Docker CLI without needing root access. sudo usermod -aG docker $USER
- Install Docker Compose using PIP, which will simply install the latest stable version:
# Install Python and PIP. sudo apt-get install -y python python-pip # Install Docker Compose into the user's home directory. pip install --user docker-compose
- Fix the Docker mounting issue in WSL terminal by inserting this content in /etc/wsl.conf. Create the file if it does not exist:
[automount] root = / options = "metdata"
Restart the machine for this setting to take effect.
- Assuming that Linux Docker VM is running, we will need to connect the Docker tools in the WSL environment to it. If we can access docker-machine from the Ubuntu terminal, we can run the eval command. Otherwise, insert the following Docker variable in the .bashrc file. We need to restart the terminal or execute source ~/.bashrc for the settings to take effect. Running Docker commands should work properly in WSL without a hitch.
[Need any further assistance to install Docker on Windows? – We’re available 24*7]
Conclusion
In short, To install Docker on windows, we need to set up a Linux virtual machine to run as a guest in Windows 10 Home. Today, we saw how our Support Engineers install docker on Windows.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
var google_conversion_label = «owonCMyG5nEQ0aD71QM»;