NixOS-WSL icon indicating copy to clipboard operation
NixOS-WSL copied to clipboard

Docker Desktop Integration fails (nativeSystemd)

Open ykis-0-0 opened this issue 2 years ago • 19 comments
trafficstars

Bug description

(Probably) outdated docker-desktop-proxy scripts prevented the integration from running.

My environment:

  • Windows 10 Pro 22H2 build 19045.2788, x86-64
  • WSL:
    > wsl -v
    WSL 版本: 1.1.6.0
    核心版本: 5.15.90.1
    WSLg 版本: 1.0.50
    MSRDC 版本: 1.2.3770
    Direct3D 版本: 1.608.2-61064218
    DXCore 版本: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows 版本: 10.0.19045.2788
    
    (核心版本 means kernel version, i guess)
  • NixOS:
    • nixpkgs: NixOS/nixpkgs@e3652e0
    • NixOS-WSL: nix-community/NixOS-WSL@64558a3

My guess on the situation:

  1. /mnt/wsl/docker-desktop/docker-desktop-user-distro now expects a mandatory argument of the socket file
  2. Docker Desktop uses uname, which doesn't exists in $PATH when called by wsl.exe -d NixOS (which itself is expected cause it's NixOS)

To Reproduce

Steps to reproduce the behavior:

  1. Set config.wsl.docker-desktop.enable to true
  2. Override systemd.services.docker-desktop-proxy with this: (To solve problem 1)
{
  systemd.services.docker-desktop-proxy = {
    path = [ pkgs.mount ];
    script = lib.mkForce ''
      ${proxyPath} proxy /run/docker1.sock --docker-desktop-root ${dockerRoot}
    '';
  };
}
  1. sudo nixos-rebuild test --flake .
  2. 💥

Expected behavior

The docker-desktop-proxy.service should load successfully on nixos-rebuild

Logs

Include relevant console logs
Mar 28 23:41:52 wslnix systemd[1]: Started Docker Desktop proxy.
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.762946480Z][docker-desktop-user-distro][I] set path configuration to InsideWslWorkspace
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.763884221Z][docker-desktop-user-distro in ][I] changed the mode of the socket /mnt/wsl/docker-desktop/shared-sockets/host-services/extension-manager.sock to 0660
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.764202208Z][docker-desktop-user-distro in ][I] ipc.NewClient: 5c7b3796-LinuxProxyCMD -> /mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock BackendAPI
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.764854214Z][docker-desktop-user-distro in ][I] ee6aa442-proxyControl : registering GET /ping
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765075981Z][docker-desktop-user-distro in ][I] ee6aa442-proxyControl : registering GET /
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765287561Z][docker-desktop-user-distro in ][I] ee6aa442-proxyControl : registering GET /goroutines/stacks
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765495568Z][docker-desktop-user-distro in ][I] ipc.NewServer: ee6aa442-proxyControl <- /mnt/wsl/docker-desktop/shared-sockets/proxy-control-.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765721237Z][docker-desktop-user-distro in ][I] ee6aa442-proxyControl : registering GET /proxy/is-restricted
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765944297Z][docker-desktop-user-distro in ][I] starting ee6aa442-proxyControl for component ProxyControlPKG on /mnt/wsl/docker-desktop/shared-sockets/proxy-control-.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: ⇨ http server started on /mnt/wsl/docker-desktop/shared-sockets/proxy-control-.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.765950552Z][docker-desktop-user-distro in ][I] ipc.NewClient: ff49204b-WSLIntegrationProxy -> /mnt/wsl/docker-desktop/shared-sockets/host-services/backend.sock BackendCLI
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.766021939Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /proxy-control <-- [2023-03-28T23:41:52.765975380+08:00] (697464ab) ipc connecting : <nil>
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.766468196Z][docker-desktop-user-distro in ][I] starting 61c53f58-dockerCLISock for component WSLIntegrationProxy on /var/run/docker-cli.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: ⇨ http server started on /var/run/docker-cli.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.766484959Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering GET /ping
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.766494807Z][docker-desktop-user-distro in ][I] add ProxyAutoResume middleware
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.767126814Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering GET /
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.767452509Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /pause/state <-- [2023-03-28T23:41:52.767435855+08:00] (51d5443d) ipc connecting : <nil>
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.767596474Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering GET /goroutines/stacks
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.767517132Z][docker-desktop-user-distro in ][W] loading versions: unmarshalling components version: open /opt/docker-desktop/componentsVersion.json: no such file or directory
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.767613659Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /proxy-control <-- [2023-03-28T19:57:09.842768800+08:00] (9c243573) proxy  : {"Locked":false,"Restricted":false}
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.768335396Z][docker-desktop-user-distro in ][I] ipc.NewServer: fa1345fd-cross-distro <- /mnt/wsl/docker-desktop/shared-sockets/guest-services/distro-services/.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.768549670Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /pause/state <-- [2023-03-28T19:57:08.209791000+08:00] (5ef226de) pause resumed : init
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.769249865Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /proxy-control <-- [2023-03-28T23:41:52.767069100+08:00] (73bdeff2) ipc ready : <nil>
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.769462671Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering POST /add-mount
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.769718235Z][docker-desktop-user-distro in ][I] 5c7b3796-LinuxProxyCMD /pause/state <-- [2023-03-28T23:41:52.768069500+08:00] (0984a28a) ipc ready : <nil>
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.770548673Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering POST /write
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.770849174Z][docker-desktop-user-distro in ][I] ipc.NewClient: 0a6aeec6-CrossDistroService -> /var/run/docker.sock WSL2DistroProxy
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.771005537Z][docker-desktop-user-distro in ][I] fa1345fd-cross-distro : registering GET /check
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:52.771209079Z][docker-desktop-user-distro in ][I] starting fa1345fd-cross-distro for component  on /mnt/wsl/docker-desktop/shared-sockets/guest-services/distro-services/.sock
Mar 28 23:41:52 wslnix docker-desktop-proxy-start[13094]: ⇨ http server started on /mnt/wsl/docker-desktop/shared-sockets/guest-services/distro-services/.sock
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [2023-03-28T15:41:54.805622368Z][docker-desktop-user-distro in ][F] symlinking credential helper: mounting resources from /run/docker1.sock: mount -t drvfs /run/docker1.sock /Docker/host -o noatime: <4>WSL (13123) WARNING: mount: waiting for virtio device drvfs
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: WSL (13123) ERROR: MountWithRetry:307: mount(drvfs, /Docker/host, 9p, 0x00000400, cache=mmap,msize=262144,trans=virtio,aname=drvfs;path=/run/docker1.sock;symlink<USER>=/mnt/) failed: No such file or directory
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: : exit status 32
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [main.run({0x7ffd25a5bb1c, 0x11})
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        linuxkit/pkg/docker-desktop-user-distro/main.go:202 +0x11b3
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [main.glob..func6(0x13af5c0?, {0xc000461170?, 0x3?, 0x3?})
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        linuxkit/pkg/docker-desktop-user-distro/main.go:86 +0x2a
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [github.com/spf13/cobra.(*Command).execute(0x13af5c0, {0xc0004610e0, 0x3, 0x3})
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        github.com/spf13/[email protected]/command.go:920 +0x847
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [github.com/spf13/cobra.(*Command).ExecuteC(0x13af2e0)
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        github.com/spf13/[email protected]/command.go:1044 +0x3bd
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [github.com/spf13/cobra.(*Command).Execute(...)
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        github.com/spf13/[email protected]/command.go:968
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [main.main()
Mar 28 23:41:54 wslnix docker-desktop-proxy-start[13094]: [        linuxkit/pkg/docker-desktop-user-distro/main.go:586 +0x25
Mar 28 23:41:54 wslnix systemd[1]: docker-desktop-proxy.service: Main process exited, code=exited, status=1/FAILURE
Mar 28 23:41:54 wslnix systemd[1]: docker-desktop-proxy.service: Failed with result 'exit-code'.

image

ykis-0-0 avatar Mar 28 '23 16:03 ykis-0-0

The docker desktop proxy's cli unfortunately doesn't seem to be stable... This is the second time it broke due to a change to the CLI. It'd be much better if we could get docker-desktop itself to start the proxy like it does on other distros, but I couldn't even get docker desktop itself to work last time I tried using it

I'll look into it further when I have the time (Likely next week)

nzbr avatar Mar 28 '23 19:03 nzbr

I tried to debug it, but I can't get Docker Desktop to work at all right now. It just keeps crashing every few minutes

nzbr avatar Apr 03 '23 17:04 nzbr

That seems strange, the Docker Desktop in my machine works pretty normal

OTOH, is it able to inject some $PATHs into the shell called by wsl.exe -d NixOS? I think that may solve the issue.

ykis-0-0 avatar Apr 04 '23 09:04 ykis-0-0

Supplementary info: bash didn't even try 😂

> wsl.exe -d NixOS echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib

> wsl.exe -d NixOS echo $-
hBc

> wsl.exe -d NixOS shopt login_shell
login_shell     off

ykis-0-0 avatar Apr 04 '23 11:04 ykis-0-0

The weird thing to me is, that Docker Desktop says that wsl.exe -d NixOS uname fails, but I can run that just fine and it returns Linux like it should. But then again: The docker engine just crashes after a few minutes, even when I try to interact with it from a Windows shell

nzbr avatar Apr 04 '23 21:04 nzbr

The weird thing to me is, that Docker Desktop says that wsl.exe -d NixOS uname fails, but I can run that just fine and it returns Linux like it should.

I wonder may that be related to the syschemd / native systemd configs. Maybe it's the native one causing some problems?

But then again: The docker engine just crashes after a few minutes, even when I try to interact with it from a Windows shell

That's really strange, did you try to set another distro as default and see if the crashing persists? Maybe that even isn't NixOS' problem.

ykis-0-0 avatar Apr 05 '23 08:04 ykis-0-0

Is there any idea which version of Docker resulted in these breaking changes? I wonder if we could temporarily work around this by pinning the version of Docker Desktop installed using winget or something similar.

LGUG2Z avatar May 31 '23 15:05 LGUG2Z

Is there any idea which version of Docker resulted in these breaking changes?

Sorry, but I've lost track of the Docker version at the time, since I had hadn't spin up Docker Desktop when I found this issue. I'm willing to do a bisect, but where could I find the old versions?

The weird thing to me is, that Docker Desktop says that wsl.exe -d NixOS uname fails, but I can run that just fine and it returns Linux like it should.

On a second thought, it maybe a misconfiguration of mine. For a comparison, May I ask the output of wsl.exe -d NixOS echo $PATH on your machine? Maybe my WSL calls the wrong bash I wonder

ykis-0-0 avatar Jun 04 '23 08:06 ykis-0-0

Docker Desktop stops crashing when I set my default distro to Ubuntu, so it's definitely a problem with NixOS and not Docker Desktop

nzbr avatar Jun 05 '23 03:06 nzbr

Docker Desktop stops crashing when I set my default distro to Ubuntu, so it's definitely a problem with NixOS and not Docker Desktop

I am seeing the same cause and effect. I have reinstalled Docker Desktop after it hangs on startup. I have tried enabling NixOS integration via Docker Desktop WSL settings as well as making NixOS my default after Docker Desktop install.

I think it is safe to say there is something in the NixOS Docker Desktop connection but I am unaware of methods to debug further.

packruler avatar Jun 05 '23 23:06 packruler

I used https://github.com/a2o/snoopy to monitor the commands Docker Desktop does to WSL instances on the first run and here is the output for Ubuntu.

In all my test, Ubuntu was the default WSL2.

Log output
Jul 30 11:19:33 DESKTOP-RYZEN snoopy[1021]: [login:vinetos ssh:((undefined)) sid:1021 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: uname
Jul 30 11:19:33 DESKTOP-RYZEN snoopy[1025]: [login:vinetos ssh:((undefined)) sid:1024 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: mkdir -p /home/vinetos/.docker/run
Jul 30 11:19:33 DESKTOP-RYZEN snoopy[1029]: [login:vinetos ssh:((undefined)) sid:1028 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: cat /home/vinetos/.docker/config.json
Jul 30 11:19:33 DESKTOP-RYZEN snoopy[1033]: [login:vinetos ssh:((undefined)) sid:1032 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: cat -
Jul 30 11:19:33 DESKTOP-RYZEN snoopy[1037]: [login:vinetos ssh:((undefined)) sid:1036 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: mkdir -p /home/vinetos/.docker/scan
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1041]: [login:vinetos ssh:((undefined)) sid:1040 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: cat /home/vinetos/.docker/scan/config.json
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1045]: [login:vinetos ssh:((undefined)) sid:1044 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: cat -
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1055]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: addgroup docker
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1056]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1057]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/00-header
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1058]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: uname -o
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1059]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: uname -r
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1060]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: uname -m
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1061]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/10-help-text
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1062]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/50-motd-news
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1063]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: cat /var/cache/motd-news
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1064]: [login:(unknown) ssh:((undefined)) sid:1052 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/]: head -n 10
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1065]: [login:(unknown) ssh:((undefined)) sid:1052 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/]: tr -d \000-\011\013\014\016-\037
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1066]: [login:(unknown) ssh:((undefined)) sid:1052 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/]: cut -c -80
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1067]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/91-contract-ua-esm-status
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1068]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/91-release-upgrade
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1071]: [login:(unknown) ssh:((undefined)) sid:1052 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/]: cut -d  -f4
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1072]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: id -u
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1068]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /usr/lib/ubuntu-release-upgrader/release-upgrade-motd
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1073]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: date +%s
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1074]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: stat -c %Y /var/lib/ubuntu-release-upgrader/release-upgrade-available
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1075]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: expr 1690708666 + 86400
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1076]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /etc/update-motd.d/92-unattended-upgrades
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1076]: [login:(unknown) ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/]: /usr/share/unattended-upgrades/update-motd-unattended-upgrades
Jul 30 11:19:34 DESKTOP-RYZEN login[1052]: pam_unix(login:session): session opened for user root(uid=0) by (uid=0)
Jul 30 11:19:34 DESKTOP-RYZEN systemd-logind[211]: New session c2 of user root.
Jul 30 11:19:34 DESKTOP-RYZEN systemd: pam_unix(systemd-user:session): session opened for user root(uid=0) by (uid=0)
Jul 30 11:19:34 DESKTOP-RYZEN systemd: pam_systemd(systemd-user:session): Runtime directory '/run/user/0' is not owned by UID 0, as it should.
Jul 30 11:19:34 DESKTOP-RYZEN systemd: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.
Jul 30 11:19:34 DESKTOP-RYZEN login[1052]: pam_systemd(login:session): Runtime directory '/run/user/0' is not owned by UID 0, as it should.
Jul 30 11:19:34 DESKTOP-RYZEN login[1052]: pam_systemd(login:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.
Jul 30 11:19:34 DESKTOP-RYZEN login[1081]: ROOT LOGIN  on '/dev/pts/4'
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1082]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: groups
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1083]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: /usr/bin/locale-check C.UTF-8
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1085]: [login:root ssh:((undefined)) sid:1052 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/root]: grep -qs i
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1086]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: lesspipe
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1087]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: basename /usr/bin/lesspipe
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1089]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: dirname /usr/bin/lesspipe
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1090]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: dircolors -b
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1091]: [login:root ssh:((undefined)) sid:1052 tty:/dev/pts/4 (0/root) uid:root(0)/root(0) cwd:/root]: mesg n
Jul 30 11:19:34 DESKTOP-RYZEN groupadd[1080]: group added to /etc/group: name=docker, GID=1001
Jul 30 11:19:34 DESKTOP-RYZEN groupadd[1080]: group added to /etc/gshadow: name=docker
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1092]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i passwd
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1093]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i group
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1094]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: sss_cache -UG
Jul 30 11:19:34 DESKTOP-RYZEN groupadd[1080]: new group: name=docker, GID=1001
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1095]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i group
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1096]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: sss_cache -G
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1097]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: addgroup vinetos docker
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1099]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i passwd
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1100]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i group
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1101]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: sss_cache -UG
Jul 30 11:19:34 DESKTOP-RYZEN gpasswd[1098]: user vinetos added by root to group docker
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1102]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: nscd -i group
Jul 30 11:19:34 DESKTOP-RYZEN snoopy[1103]: [login:root ssh:((undefined)) sid:1051 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: sss_cache -G
Jul 30 11:19:35 DESKTOP-RYZEN snoopy[1190]: [login:vinetos ssh:((undefined)) sid:1189 tty:(none) ((none)/(none)) uid:vinetos(1000)/vinetos(1000) cwd:/mnt/c/Users/Vinetos/AppData/Roaming/Docker]: ps -x
Jul 30 11:19:36 DESKTOP-RYZEN snoopy[1214]: [login:root ssh:((undefined)) sid:1199 tty:(none) ((none)/(none)) uid:root(0)/root(0) cwd:/root/.docker/desktop]: /sbin/mount.drvfs C:\Program Files\Docker\Docker\resources /Docker/host -o rw,noatime

As we can see on the last line, Docker Desktop is mounting a Windows folder to /Docker/host in the WSL.

/sbin/mount.drvfs C:\Program Files\Docker\Docker\resources /Docker/host -o rw,noatime

After trying some dumb arguments for the docker-desktop-user-proxy, It seems that the CLI wants the Windows path of resources folder which will be mounted to /Docker/host . I can successfully launch the proxy manually with sudo /mnt/wsl/docker-desktop/docker-desktop-user-distro proxy "C:\Program Files\Docker\Docker\resources".

But docker ps does not work on another terminal. (See why in UPDATE 2)

[vinetos@wsl:~]$ sudo docker ps
fork/exec /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli: no such file or directory

[vinetos@wsl:~]$ /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli
-bash: /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli: cannot execute: required file not found

Probably a missing file or something like that. (See why in UPDATE 2)

Also, running /mnt/c/Program\ Files/Docker/Docker/resources/com.docker.diagnose.exe check give me : [FAIL] DD0014: are the backend processes running? 1 error occurred: * com.docker.vpnkit.exe is not running

My Investigation continue.

UPDATE 1: After updating the systemd script to add the folder C:\Program Files\Docker\Docker\resources, I can reproduce the same behavior as running the command manually :

systemd.services.docker-desktop-proxy = {
        description = "Docker Desktop proxy";
        path = [ pkgs.mount ];
        script = ''
          ${config.wsl.wslConf.automount.root}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.wslConf.automount.root}/wsl/docker-desktop "C:\Program Files\Docker\Docker\resources"
        '';
        wantedBy = [ "multi-user.target" ];
        serviceConfig = {
          Restart = "on-failure";
          RestartSec = "30s";
        };
      };

      users.groups.docker.members = [
        config.wsl.defaultUser
      ];

    };

But docker ps still not working because it calls the executable of docker-desktop (the WSL distribution).

UPDATE 2: A work around is the use the host command-line tools to run the docker command successfully.

I can use /Docker/host/bin/com.docker.cli.exe run hello-world successfully but /Docker/host/bin/docker does not works still (see UPDATED 3).

image

Using alias docker=com.docker.cli.exe in the terminal allow me to run all docker commands by passing through Windows.

Docker Desktop still fails when using NixOS as default WSL2 probably because the weird alias tricks.

UPDATE 3: The script located in C:\Program Files\Docker\Docker\resources\bin\docker (mounted in /Docker/host/bin/docker) is used to pass Windows docker command to WSL. This is why the "host" docker command is not working. Here is the script :

#!/usr/bin/env sh
#
# Copyright (c) Docker Inc.

binary=$(basename "$0")
case "$(uname -r)" in
    *microsoft* )
        # WSL 2
        if [ -f "/usr/bin/$binary" ]; then
            # It seems this script ran before the integration added the real binary.
            # Run the real binary for the user.
            set -e
            "/usr/bin/$binary" "$@" # <============== here
        else
            echo
            echo "The command '$binary' could not be found in this WSL 2 distro."
            echo "We recommend to activate the WSL integration in Docker Desktop settings."
            echo
            echo "For details about using Docker Desktop with WSL 2, visit:"
            echo
            echo "https://docs.docker.com/go/wsl2/"
            echo
            exit 1
        fi
        ;;
    *Microsoft* )
        # WSL 1
        echo
        echo "The command '$binary' could not be found in this WSL 1 distro."
        echo "We recommend to convert this distro to WSL 2 and activate"
        echo "the WSL integration in Docker Desktop settings."
        echo
        echo "For details about using Docker Desktop with WSL 2, visit:"
        echo
        echo "https://docs.docker.com/go/wsl2/"
        echo
        exit 1
        ;;
    * )
        # No WSL, maybe MINGW, try Windows exe which should also be in PATH
        "$binary.exe" "$@"
        ;;
esac

The line "/usr/bin/$binary" will execute/usr/bin/docker which will fail.

[vinetos@wsl:~]$ ls -sla /usr/bin/ | grep docker
0 lrwxrwxrwx 1 root root   56 Jul 30 16:22 com.docker.cli -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/com.docker.cli
0 lrwxrwxrwx 1 root root   48 Jul 30 16:22 docker -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker
0 lrwxrwxrwx 1 root root   56 Jul 30 16:22 docker-compose -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose
0 lrwxrwxrwx 1 root root   59 Jul 30 16:22 docker-compose-v1 -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-compose-v1
0 lrwxrwxrwx 1 root root   46 Jul 30 16:22 docker-credential-desktop.exe -> /Docker/host/bin/docker-credential-desktop.exe
0 lrwxrwxrwx 1 root root   54 Jul 30 16:22 docker-index -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker-index
0 lrwxrwxrwx 1 root root   50 Jul 30 16:22 hub-tool -> /mnt/wsl/docker-desktop/cli-tools/usr/bin/hub-tool

So, executing the docker bin from docker-desktop in the NixOS WSL fails because of "missing file" (maybe PATH + LIB issue).

Using the Windows host to pass docker commands (and bypassing the docker script) can be a temporary fix.

Another solution is to use the nix-packaged docker client. By running /nix/store/<HASH>-system-path/bin/docker ps, the Docker client works fine too. But, It will not make the other CLI tools (hub-tool, docker-index) available but the docker command will be working if we override these paths. And that's could be why Docker Desktop fails.

What do you think ?

Vinetos avatar Jul 30 '23 11:07 Vinetos

For the record, when I run the proxy exe on my machine (also nativeSystemd, Docker v4.21.1), it doesn't even get past the first WSL command. The output is

PS C:\Users\kfish> & 'C:\Program Files\Docker\Docker\resources\com.docker.wsl-distro-proxy.exe' --distro-name NixOS
[2023-07-31T02:49:35.712300000Z][com.docker.wsl-distro-proxy.exe.paths][I] set path configuration to OnHost
[2023-07-31T02:49:35.712300000Z][com.docker.wsl-distro-proxy.exe][I] start wsl integration for distro NixOS
[2023-07-31T02:49:35.712818000Z][com.docker.wsl-distro-proxy.exe.linuxworkspaces][I] wsl.exe -d NixOS -e sh -c mkdir -p ~/.docker/run
[2023-07-31T02:49:35.853652800Z][com.docker.wsl-distro-proxy.exe][F] unable to create ~/.docker/run directory: exit status 127
[main.main()
[       win/backend/cmd/com.docker.wsl-distro-proxy/main.go:138 +0xe4b

Indeed, when I run wsl.exe -d NixOS -e sh -c mkdir -p ~/.docker/run in Powershell, I do get an exit code 127 (-p: line 1: mkdir: command not found), though I do not get the same exit code if I run sh -c mkdir -p ~/.docker/run in WSL; I get exit code 1 (mkdir: missing operand). Not sure what's up with that.

kfish610 avatar Jul 31 '23 03:07 kfish610

Indeed, when I run wsl.exe -d NixOS -e sh -c mkdir -p ~/.docker/run in Powershell, I do get an exit code 127 (-p: line 1: mkdir: command not found), though I do not get the same exit code if I run sh -c mkdir -p ~/.docker/run in WSL; I get exit code 1 (mkdir: missing operand). Not sure what's up with that.

What version are you running ? Before my tests, I have updated WSL2 (wsl --update) and used the last version of the installer (23.05 on master here) and switch to unstable inputs (my configuration : https://github.com/Vinetos/nixos ).

Does it run if you log into the WSL ? I have only tested with the service and by opening a shell. Maybe it's another king of bug that make impossible to run command without dropping into a shell.

EDIT: This is linked to https://github.com/nix-community/NixOS-WSL/issues/222 because Windows skips the shell wrapper

Vinetos avatar Jul 31 '23 07:07 Vinetos

Hi,

I just installed a fresh NixOS-WSL, when I enable Docker Desktop in /etc/nixos/configuration.nix, I get this error,

     Loaded: loaded (/etc/systemd/system/docker-desktop-proxy.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Sun 2024-01-28 12:57:04 UTC; 286ms ago
    Process: 3655 ExecStart=/nix/store/qzqkfrkd9hh0f80zb9sb1hw79bhfm30j-unit-script-docker-desktop-proxy-start/bin/docker-desktop-proxy-start (code=exited, status=1/FAILURE)
   Main PID: 3655 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 18ms
warning: error(s) occurred while switching to the new configuration

Manually running the script fails as well.

Command:

sudo /nix/store/qzqkfrkd9hh0f80zb9sb1hw79bhfm30j-unit-script-docker-desktop-proxy-start/bin/docker-desktop-proxy-start

Error:

Error: accepts 1 arg(s), received 0
[2024-01-28T13:05:01.670402107Z][docker-desktop-user-distro][F] accepts 1 arg(s), received 0
[main.main()
[       linuxkit/pkg/docker-desktop-user-distro/main.go:594 +0x50

I assume a path as an argument is missing from the script as mentioned here ?

Any suggestion ?

daspk04 avatar Jan 29 '24 01:01 daspk04

I tried to install NixOS-WSL2 and integrate with Docker Desktop on W10 and I am receiving similar errors. Is there any workaround or fix for this to get nixos integrated with docker desktop and kubernetes?

RyzeNGrind avatar Jan 30 '24 00:01 RyzeNGrind

I tried to install NixOS-WSL2 and integrate with Docker Desktop on W10 and I am receiving similar errors. Is there any workaround or fix for this to get nixos integrated with docker desktop and kubernetes?

Hi @RyzeNGrind,

I tried to follow as suggested here. This seems to work for me.

Basically this is my configuration for wsl:

  wsl = {
    enable = true;
    wslConf.automount.root = "/mnt";
    wslConf.interop.appendWindowsPath = false;
    wslConf.network.generateHosts = false;
    defaultUser = username;
    startMenuLaunchers = true;

    # Enable integration with Docker Desktop (needs to be installed)
    docker-desktop.enable = false;

    extraBin = with pkgs; [
      # Binaries for Docker Desktop wsl-distro-proxy
      { src = "${coreutils}/bin/mkdir"; }
      { src = "${coreutils}/bin/cat"; }
      { src = "${coreutils}/bin/whoami"; }
      { src = "${coreutils}/bin/ls"; }
      { src = "${busybox}/bin/addgroup"; }
      { src = "${su}/bin/groupadd"; }
      { src = "${su}/bin/usermod"; }
    ];
  };

  virtualisation.docker = {
    enable = true;
    enableOnBoot = true;
    autoPrune.enable = true;
  };

  ## patch the script 
  systemd.services.docker-desktop-proxy.script = lib.mkForce ''${config.wsl.wslConf.automount.root}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.wslConf.automount.root}/wsl/docker-desktop "C:\Program Files\Docker\Docker\resources"'';
  • I kept docker-desktop.enable = false from NixOS but I enabled it from the host (i.e. windows) Docker Desktop.
❯ which -a docker
/usr/bin/docker
/run/current-system/sw/bin/docker

Possible because of this, as Docker Desktop on host (windows) expects no docker to be installed inside the distro and the official document suggests it to be removed and given that NixOS distro already has a docker installed possibly that creates a conflict:

  • The second path /run/current-system/sw/bin/docker is the one that works fine and shows the container and images that I already have on my host system.
/run/current-system/sw/bin/docker info
 or
sudo /run/current-system/sw/bin/docker info

##  Docker info
Client:
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.0-desktop.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.23.3-desktop.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.21
    Path:     /usr/local/lib/docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  0.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.10
    Path:     /usr/local/lib/docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.2.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scout

Server:
 Containers: 9
  Running: 1
  Paused: 0
  Stopped: 8
 Images: 11
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 5.15.133.1-microsoft-standard-WSL2
 Operating System: Docker Desktop <----------------------- Check this
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 27.41GiB
 Name: docker-desktop  <------------------------------------- Check this
 ID: ce4faac5-bea5-4a89-88a4-bbc39da52da6
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile
  • Basically if you see the info printed from docker info for Server points to docker desktop distro which is what is correct at least in my understanding as mentioned in Docker official Doc
Operating System: Docker Desktop
Name: docker-desktop
  • Optional : One can also created an alias for /run/current-system/sw/bin/docker as docker for the shell in nix configuration.
 docker = "/run/current-system/sw/bin/docker";

Summary:

  • Keep docker-desktop.enable = false;
  • Create some extra bin in configuration.nix
  • Integrate it with NixOS distro from Docker Desktop on host (windows)
  • Run via /run/current-system/sw/bin/docker

daspk04 avatar Feb 11 '24 04:02 daspk04

Brilliant solution! I was banging my head on the wall for hours. god bless this voodoo magic.

schlich avatar Mar 05 '24 04:03 schlich

Thanks for the solution! All I had to do was add the wsl.extrabin option for my Docker Desktop to work.

Mach1212 avatar Apr 14 '24 02:04 Mach1212

The docker-desktop-user-distro proxy command line api (this program is on windows, so cannot be managed by NixOS) keeps changing as one updates docker desktop version.

So I decide to override the systemd configuration here: https://github.com/nix-community/NixOS-WSL/blob/f373ad59ae5866f0f98216bd5c71526b373450d2/modules/docker-desktop.nix#L23-L33

I made it as a module:

# /etc/nixos/modules/docker-desktop-fix.nix
{
  config,
  lib,
  pkgs,
  ...
}:
with lib;
{

  options.fix.docker-desktop.enable = mkEnableOption "docker desktop fix";

  config =
    let
      resources = "C:\\Program Files\\Docker\\Docker\\resources";
    in
    mkIf (config.wsl.docker-desktop.enable && config.fix.docker-desktop.enable) {
      systemd.services.docker-desktop-proxy = {
        script = mkForce ''
          ${config.wsl.wslConf.automount.root}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.wslConf.automount.root}/wsl/docker-desktop '${resources}'
        '';
        path = [ pkgs.mount ];
      };
    };
}

To apply the override, simply import it in your configuration.nix file and enable it.

# /etc/nixos/configuration.nix
{
  config,
  lib,
  pkgs,
  ...
}:

{
  imports = [
    # ...
    ./modules/docker-desktop-fix.nix
  ];

  # ...

  wsl.docker-desktop.enable = true;
  fix.docker-desktop.enable = true;
}

lyra95 avatar Jul 30 '24 19:07 lyra95