Skip to content

Instantly share code, notes, and snippets.

@lure
Last active March 9, 2021 03:58
Show Gist options
  • Select an option

  • Save lure/e529a2fe7d8d8c8619f695e36c7e017a to your computer and use it in GitHub Desktop.

Select an option

Save lure/e529a2fe7d8d8c8619f695e36c7e017a to your computer and use it in GitHub Desktop.
WSL | DockerDesktop

WSL default user and preserve file cetting( ~/.ssh)

To puth into /etc/wsl.conf

If chmod or chown takes no effect on files disk should be mounted with metadata like this.

[automount]
options = "metadata"

Sometimes WSL decide to start the session as a root. Fix it with this snippet

[user]
default=alex

Docker-desktop on windows with WSL

No free space on system drive

Let's sat you got windows host with docker desktop and free space on c: suddenly disappear. Seeking lead you to %LOCALAPPDATA%/Docker/wsl where you see *.vhxd file of 32gb size. You can not find any relative settings in docker-desktop GUI (this is because WSL support is enabled btw), but you want this file to be moved to another disk, let's say e:

move VHDX file to another disk

Open command prompt, and there do

wsl shutdown 
wsl --export  docker-desktop-data  e:\dockerdesktop\docker-desktop-data.tar
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data E:\dockerdesktop\data\ e:\dockerdesktop\docker-desktop-data.tar --version 2 

Pay attention that no paths are starting or contain underscores or hyphens or dashes - wsl work really poorly with them and wsl's bash does even worse. After all command completed, restart docker desktop, delete e:\dockerdesktop\docker-desktop-data.tar you no longer need it.

Sources of dark knowledge:

how: microsoft/WSL#4320 (comment) what: https://docs.docker.com/docker-for-windows/wsl/ why: https://docs.microsoft.com/en-us/windows/wsl/compare-versions#understanding-wsl-2-uses-a-vhd-and-what-to-do-if-you-reach-its-max-size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment