Installing Docker on Windows and Linux
Tags: docker, devops, virtualization, wsl2
Published: 2021-09-08 14:01:55


When it comes to devops it’s near impossible that you haven’t heard about Docker. So what is docker and how can you install it on your device? To put in a simple words docker is a containerization platform allowing developers to package applications into containers. With containers we can run anything from a small microservice or software process to a larger application. Containers contain all the necessary executable binary code, libraries and configuration files, spin up the container and you get your own virtualized application ready to use at a moment's notice. Without any more delay let’s move on to the docker installation process. Docker container engine is entirely dependent on the container features provided by the Linux kernel. Does that mean you cannot run docker on windows, Yes you can!

Docker on Linux
       To install docker on Linux we have to simply run a command that's it. You can install docker using apt 'sudo apt-get install docker.io' or by yum 'sudo yum install docker.io' preference is yours.
            

Docker on windows
       Now, installing docker on windows is not as easy as installing on Linux. There are two ways to do so 

1] Using VMware or VirtualBox
         Install your preferred edition of VMware or VirtualBox and then download your preferred Linux flavor on it. After that follow simple command given on Docker on Linux.

2]Using wsl2
         It gets bit trickier when it comes to installing docker with this step as there are few more steps involved first time. So why the extra hassle?
         Using the wsl2 (Windows Subsystem for Linux) backend we can directly (well actually you are still running docker on Linux) run docker on windows you won't need to use VMware or VirtualBox. Just click on the docker app and that's it simple and fast.
         First of all you would need to enable wsl2 and install your favorite Linux flavor on it. You can do that with two simple commands (previously there were n number of things you have to go through to just install wsl2 but thankfully Microsoft has simplified the process, now those steps are done in background).
         To see a complete list of available Linux distributions, enter 'wsl --list --online' as by default ubuntu is installed. Now from the list select the destro you want to install and type the command  'wsl --install -d Distribution_Name'. Here replace Distribution Name with your preferred destro. After the install your windows device will restart and wsl2 will be ready.
          Now moving on to next step go to docker desktop (site:https://www.docker.com/products/docker-desktop) download the Docker Desktop Installer run it and your docker app is ready to use.
           But what if I want to run docker on wsl2 and use virtualization at the same time as I don't want to open VM just to run docker? (Question which prompted me to search would it break my system? and to write this article). Then there are few things to check and you would be able to use wsl2 and VM at the same time.
          As per the windows version requirement you would need Windows 10 20H1 or higher (Minimum build number should be 19041). Type 'winver' command in search bar of your windows laptop and you would get required info. And you should be running VMware 16 at least (both free and paid versions would work). If you got VMware Workstation 15.5 it would still work neat. 
         

[This is to run Linux container directly on windows we are not talking about windows container. As Linux containers run by default on docker we have to  change the settings on docker to run windows containers.]
Note : Don't click on the links or run commands available on internet without verifying. 

If you liked above article hit me follow here and on [twitter](https://twitter.com/Anon_kn9).