First, install WSL for windows : search from start menu for “Turn Windows features on or off” and select “Windows Subsystem for linux”
Next, install ubuntu:
wsl --set-default-version 2 wsl --install -d Ubuntu
Go in Ubuntu:
wsl -l -v wsl -d Ubuntu
From there, install docker:
sudo apt-get update sudo apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.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 -y install docker-ce docker-ce-cli containerd.io sudo groupadd docker sudo usermod -aG docker $USER
To start:
sudo service docker start
To automatically start at startup, add at the end of the file:
vi ~/.bashrc if (! pgrep dockerd > /dev/null); then sudo service docker start fi
And also in order to not require a password for the above command, add to the end:
sudo visudo your-username ALL=(ALL) NOPASSWD: /usr/sbin/service docker start
Now you can run wsl docker commands.
To get rid of the wsl prefix save this as docker.bat in C:\Windows:
@echo off wsl docker %*
Open Notepad and create a batch script with the following command:
@echo off wsl -d Ubuntu
Save the file as `start_wsl.bat` in the `C:\Windows` directory.
Create a shortcut to the batch file.
Right-click on the `start_wsl.bat` file, and choose Create Shortcut.
Next, set the shortcut to run minimized:
Then, move the shortcut to the Windows Startup folder:
Now, WSL (Ubuntu) will automatically start whenever Windows boots up, without showing the CMD window.