Docker installation on Windows with WSL2 backend
Tags: docker, windows, linux, installation
Published: 2023-04-02 09:07:24

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hco7bxg23ifcnon4to9e.png
title: Docker installation on Windows with WSL2 backend
published: true
date: 2023-01-20 12:17:21 UTC
tags: docker, windows, linux, installation
canonical_url: 
---

Well, I have finally decided to start my blogging journey with this very first article on how to install docker🐳 on your windows pc💻.

Recently I started learning about DevOps and I can't explain how happy😄 I am to make this decision. But before I could indulge myself in the world of DevOps I had to face the biggest obstacle!

### Installing docker on my pc........😶

![gif](https://media.giphy.com/media/l2JdSxPExdAmkMelO/giphy.gif)

Yes. Yet another setup war🔫. By now I was used to such issues because as a computer science student, you are meant to deal with new software installation issues on a weekly if not daily basis (\*\*exaggeration is needed). But this one was for me the toughest yet. Since the Docker container uses the kernel of the host machine many prerequisites are needed to take care of before you can install it on your pc. This is one major drawback when compared to Virtual Machines since they have their kernel.

So how did I win over this catastrophe?? Well, I did spend a lot of time watching tutorials and doing some random trials by myself to finally have the docker engine running on my machine and I will share those steps below to help you all too. Just remember, be patient and the angels will guide you..👼

* * *

## Steps to follow:

* Since knowing how to write Linux commands is important for a DevOps learner, I will recommend you enable WSL(Windows Subsystem for Linux) on your windows machine. You can do so by searching for "Turn Windows Features On or Off" in the search bar and a popup will then appear where you must make sure that the WSL checkbox is marked checked ✅.

> Docker allows WSL integration so it's better to run a Linux distribution on your Windows machine. We are achieving 2 things here; one, you can run bash commands now on Windows and two, Docker can run with a WSL backend. (It also allows Hyper V integration but we will focus on WSL for now.)

![Turn Windows Features On or Off](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ll3pfew6oyz7dz20i40.jpg)


* Now once that is done we can move on to installing a Linux distribution on our pc. Go to Microsoft Store and choose any one distro. I prefer Ubuntu so go ahead and install that on your machine. Feel free to choose any other like Debian, Kali Linux, etc, Ubuntu is just the most popular one.
![Microsoft Store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ooajm5jzrys1dy4w02ma.jpg)


* Now open the Ubuntu app and wait for it to install. It will then prompt you with a username and a password so just write something that you will not forget especially the password because while running 'sudo' bash commands in the future you will be asked for the password every time. Once that is done bash is finally installed on your pc and now you can write some cool Linux commands to show off! You can open your favorite terminal like the command prompt or maybe Windows PowerShell and then launch the command **bash** to enter the bash shell. If it shows your _username@something_ then you have successfully logged in as that user into the shell.
![terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aitgsbemhkmvaezhi12v.jpg)


* Now we must encounter the most important part. Before installing Docker Desktop check the version of WSL by writing the command **_<mark>wsl -l -v</mark>_**. If you see the version of your installed Linux distro as 2 then you can go ahead with the next step (Just make sure that Virtualization is enabled in your pc by checking BIOS. If you are not sure what that means keep reading).
Else if the version is 1 which has a higher chance then we must do 2 things to change it to version 2.
**First**, enable virtualization in your pc by entering BIOS. You can check whether it's enabled or not by opening the task manager and checking the performance tab.
![Virtualization](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsyo8rj5mxddr03frffh.jpg)

If it's not then don't worry we can enable it very simply. Depending on your pc find out the hotkeys(generally f1, f2, f10, Esc..). Now restart your pc and before you can see the logo of your pc click the hotkey to enter your BIOS directly. For my pc, it worked like that but for others, it might be different so make sure to check this link out: [Enable Virtualization with BIOS](https://www.simplilearn.com/enable-virtualization-windows-10-article)

**Second**, you must install the Linux kernel package for WSL2 on your pc. For this, you need to visit the link given below and go to Step 4 where a download link is provided. [Install the WSL2 Linux kernel update package](https://learn.microsoft.com/en-us/windows/wsl/install-manual)

Now run the downloaded application to finish installing it on your pc and after that, you can finally change the version of your WSL distro by running the command `wsl --set-version <distro_name> 2` in your terminal. Check the version again to confirm it's converted. 
![terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u5b6qtuwv8f84wzs3l1u.jpg)


* Now, you can install Docker Desktop for Windows from their official site and then run it to finish the installation. In the middle, if it asks you for choosing WSL2 for integration then make sure you check it before clicking continue. Finally, accept the terms and voila!! Your Docker Desktop is installed!!🎉


* Open it to see if the docker engine is running or not. If you see that the engine is stuck in the starting phase and even the settings are taking forever to load then you might have to switch your containers from Windows to Linux. I tried it and it worked for me. Just simply go to the taskbar and right-click on the docker icon. It will give you an option called "Switch to Linux Containers". Click on it and wait. Your engine will stop and then start again.


* Finally, it will start running and you will be able to see something like this:
![docker desktop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3rdy28kign9whuofdpk.jpg)
I already had some local containers running so you are seeing the dashboard like this but yours will be initially empty.



* Make sure that in **Settings>Resources>WSL integration** your distro is enabled. Or else you won't be able to write docker commands from your bash. If not then enable and click on Apply and Restart.
![docker desktop integrations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mc73rlwsrne5n38qi4he.jpg)


* Finally, check if you can run docker commands from your bash or not by launching the command **_<mark>docker</mark>_**. If you get something like the below then it's perfectly working.
![terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9fsjpa36lav6ydbnzfi.jpg)


![gif](https://media.giphy.com/media/DhstvI3zZ598Nb1rFf/giphy-downsized-large.gif)


Yayyyyy!! Now you can do some cool stuff with Docker🐳. I am currently following tutorials of [TechWorldWithNana](https://www.youtube.com/@TechWorldwithNana)👧 and [Kunal Kushwaha](https://hashnode.com/@kunalk)👦to learn DevOps and I hope you will like them too. Their explanations are amazing, especially for beginners!

Well, with that being said I have to bring an end to this article by saying that it felt really good blogging for the first time and I wish to do more in the future.

Please look forward to it..🤗💙