Enabling network connectivity in WSL 2 windows and running docker in windows.
--
Install wsl2:
follow the steps:
follow the manual steps in:
Note: RESTART your system after step 2 before proceeding to step 4 in above guide
After step 5 follow the below steps
Install distros:
we use Ubuntu 20.04 LTS
Launch Ubuntu:
launch Ubuntu by typing Ubuntu in start menu
setup the system by providing any username and password of your choice
Enabling network connectivity:
OK this is the tricky part ,
the hack I do is ,
- first switch the distros into wsl 1 and install ifconfig
to do this open powershell as admin and run:
wsl -l -v
copy the name and then switch the distro wsl version
wsl.exe --set-version Ubuntu-20.04 1
now launch ubuntu again and install ifconfig
sudo apt-get update
sudo apt install net-tools
now switch back to wsl 2:
wsl.exe --set-version Ubuntu-20.04 2
Check wsl lan network ip by running ipconfig in powershell
ipconfig
Now launch ubuntu again and check eth0
you can observe that the network is down , so you have to configure it properly as:
sudo ifconfig eth0 <IPv4 address in samenetwork> netmask <samenetmask>
sudo route add default gw <ipaddressofwindowswsl>