Skip to content

Instantly share code, notes, and snippets.

@tomasfejfar
Last active March 14, 2021 16:14
Show Gist options
  • Save tomasfejfar/c3ac0d795dfadb13b7ef813d3e9410d3 to your computer and use it in GitHub Desktop.
Save tomasfejfar/c3ac0d795dfadb13b7ef813d3e9410d3 to your computer and use it in GitHub Desktop.
WSL2 docker setup for Windows
# based on https://susi.dev/dev-env-2020#5-use-systemd-hack-to-use-snap-optional-be-careful
# in windows
& 'C:\Program Files\VcXsrv\vcxsrv.exe' :0 -multiwindow -wgl -ac -silent-dup-error
# add firewall rule
netsh advfirewall firewall add rule name="XServer" dir=in program="C:\program files\vcxsrv\vcxsrv.exe" protocol=TCP localport=6000 action=allow profile=private remoteip=localsubnet
# in ubuntu
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
snap version
# in ubuntu export DISPLYA variable
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment