Skip to content

Instantly share code, notes, and snippets.

@Eboubaker
Last active December 17, 2021 18:35
Show Gist options
  • Save Eboubaker/f11d4ed4a2cbe1081e3a1e93f76f154a to your computer and use it in GitHub Desktop.
Save Eboubaker/f11d4ed4a2cbe1081e3a1e93f76f154a to your computer and use it in GitHub Desktop.
1 click install WSL and docker on windows

1 click install WSL and docker on windows

In privileged powershell

#Powershell in Administrator mode
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
# install choco
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Restart-Computer -Confirm

After restart

#Powershell in Administrator mode
wsl.exe --set-default-version 2
choco install wsl-ubuntu-2004 -yf

if --set-default-version 2 failed you may need to install the update manually from https://aka.ms/wsl2kernel

Install docker with choco

#Powershell in Administrator mode
choco.exe install docker-desktop
Restart-Computer -Confirm

If everything worked you might want to update the apt packages log in to ubuntu by running wsl.exe in cmd or powershell then run

sudo apt-get update
sudo apt-get install

Bonus: running a laravel app with swoole

In WSL Ubuntu

curl -s https://laravel.build/sailapp | bash
cd sailapp
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
sail up -d
sail composer require swooletw/laravel-swoole

add 8000 port mapping in docker-compose.yml and then restart sail and run

sail artisan swoole:http start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment