Categories
Linux Windows WSL

Easiest way to bridge WSL (windows subsystem for linux)

Its really hard to use WSL2 like a linux box due to how hard it is to make incoming connections from other machines to your WSL instance.

Well a new an hidden feature in the latest WSL preview fixes that. You will need at least version 0.51.2.0 to implement bridging to the host. Here is how to implement it.

  1. issue the wsl –shutdown command
wsl --shutdown
  1. install a new virtual switch using Hyper-V say wsl-switch
  2. to %userprofile%\.wslconfig add the following (if the file doesn’t exist create it)
[wsl2]
networkingMode=bridged
vmSwitch=wsl-switch

Now when you restart WSL you will have a bridge session. This has also be known to cure some of the weird network issues seen with WSL where network connectivity stops working, no DNS connectivity – without the need for messing with scripts and config files. YMMV

Categories
containers docker Linux

Installing docker on Linux – the easy (and official) way.

**updated 3/14/22 to use docker compose v2**

When i first started to learn how to install docker on raspberry pi, Linux, etc i found many large articles with many steps to tell me how to do it – pages of commands and instructions.

I don’t know why they make it so hard and the ‘received wisdom’ of 5 years ago is still repeated to this day (modern search engines don’t help). I think you will find this simpler, it is the official supported docker way to do this.

Install your preferred linux distro and ssh into it (don’t bother with gui).

For Distros like Debian after you install, login and have root privileges do the following

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo apt-get install docker-compose-plugin
$ sudo service docker start

The great part of doing it this way is you can rerun the script to do updates or even just use apt-update \\ apt-upgrade.,

For OS that doesn’t have python 3 installed by default (for example Raspbian) you need to do a couple of extra steps:

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo usermod -aG docker pi
$ sudo apt-get install docker-compose-plugin

Hope that helps.

Bonus for those who need more of a breadcrumb trail and know how to create VMs but want linux help….

  • Download latest Debian ISO (i prefer full install just incase networking gives you grief)
  • Create VM
    • 200GB
    • 2 CPU
    • 4GB RAM
  • Boot from CD and choose non graphical install of debian with SSH and tools only.
  • Create root and yourusername as prompted
  • Login as root on console, install basics:
    • apt-get update
    • apt-get upgrade
    • apt-get install nano sudo curl
  • Add user to sudo group
    • usermod -aG sudo yourusername
  • Login via SSH as yourusername and sudo every command from this point forward
  • Install docker
    • curl -fsSL https://get.docker.com -o get-docker.sh
    • sudo sh get-docker.sh
    • sudo apt-get install docker-compose
    • sudo service docker start