Hi guys, it’s been a while since I’ve had the opportunity to write a tutorial about Docker. This article is intended for those of you who are, are, will be using Docker at work. So, if you are new to Docker, you should learn first and come back here later.
As you know, installing docker on Linux is quite easy, with just a few commands on the terminal, the config setup takes place automatically. But on Windows is very different and difficult. That is why the Docker programming team builds Docker Desktop applications to support running Docker containers on Windows.
No more rambling, on any topic.
Install Docker Desktop
On Windows, install Docker Desktop Installer following this link: https://desktop.docker.com/win/stable/Docker Desktop Installer.exe , there are many options but I recommend choosing from recommendation.
After installation is complete, in the lower right corner will display the icon of Docker Desktop and its status. There are 3 states: Stopping, Restarting and Running.
Right-clicking on the Docker icon will bring up the options. Here I choose Dashboard
This is the main interface of Docker Desktop
There are two ways to get to Settings (this is very important).
- Right-click the docker icon and select Settings
- Go to the main interface as shown above and select the gear icon
Here happen 2 cases:
- You choose to use Windows Container as the backend engine
- You choose to use WSL 2 as the backend engine
Both ways have pros / cons to compensate. As you use Windows Container, the setup is simple because Windows 10 supports all of it, but it is so miserable that it doesn’t run smoothly with WSL 2. And if you use method 2, it runs better than method 1 but setup is cumbersome.
I will guide you the first way: using Windows Container
- Go to Apps & Features, an item in Windows Settings
- Go to the Programes and Features section in the upper right corner
- Go to Turn Windows features on or off
- You select 2 boxes
Hyper-Vin the picture below
- Restart the machine
If you use this way, in the Settings section of Docker Desktop there will be a section to set the machine resources of each Docker Container and set the path to mount the directory in the Container with the outside.
After adjusting ok, click Apply & Restart to save changes.
Ok so that’s way 1, let’s move on to method 2.
Installing WSL 2
- Enable Windows Subsystem for Linux by Windows CMD, type this line:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Check the machine configuration for the conditions
- For x64 systems: Version 1903 or higher, with Build 18362 or higher.
- For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
- Turn on the Virtual Machine feature
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Download the Linux kernel update package via the link https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
- Make WSL 2 the default when installing Linux distribution
wsl --set-default-version 2
- Basically, doing the above step is ok but if you want to use Ubuntu or Kali or Debian, go to Microsoft Store to download Linux distributions ( https://aka.ms/wslstore )
- Then Linux will ask you to create Username, Password types but only once
If you use WSL 2 as the backend, you do not need to worry about changing the Docker Desktop Settings like machine resources to use or mount paths in / out of the container because everything is already configured.
Ok that’s done, it’s a short song for a peaceful life.