Repository navigation
Description
Windows Version
Microsoft Windows [Version 10.0.19045.3448]
WSL Version
2.0.9.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.133.1-1
Distro Version
Ubuntu 22.04
Other Software
Docker CE, version 24.0.7. Installed on WSL2 from Docker's apt repo.
Notepad.exe
Repro Steps
I am working on a project that needs to run Windows applications from inside of a WSL2 Docker container. When I try to launch a Windows application directly (notepad.exe used as an example), I get a strange failure. The failure doesn't occur if I launch it from inside of a shell instead.
Inside of WSL2 (with dockerd running as sudo in another tab), this command fails:
docker run --rm -it --privileged --mount type=bind,source=/mnt,target=/mnt \
--mount type=bind,source=/run/WSL,target=/run/WSL \
--mount type=bind,source=/etc/passwd,target=/etc/passwd,readonly \
--mount type=bind,source=/etc/group,target=/etc/group,readonly \
--mount "type=bind,source=$HOME,target=$HOME" \
--workdir "$HOME" \
-u $(id -u):$(id -g) \
--env WSLENV="${WSLENV}" \
--env WSL_DISTRO_NAME="${WSL_DISTRO_NAME}" \
--env WSL_INTEROP="${WSL_INTEROP}" \
--env WT_PROFILE_ID="${WT_PROFILE_ID}" \
--env WT_SESSION="${WT_SESSION}" \
ubuntu \
'/mnt/c/Windows/system32/notepad.exe'
with the following error:
<3>WSL (1) ERROR: ConfigInitializeEntry:1621: Failed to mount (null) at /dev as devtmpfs 1
but this one succeeds OK:
docker run --rm -it --privileged --mount type=bind,source=/mnt,target=/mnt \
--mount type=bind,source=/run/WSL,target=/run/WSL \
--mount type=bind,source=/etc/passwd,target=/etc/passwd,readonly \
--mount type=bind,source=/etc/group,target=/etc/group,readonly \
--mount "type=bind,source=$HOME,target=$HOME" \
--workdir "$HOME" \
-u $(id -u):$(id -g) \
--env WSLENV="${WSLENV}" \
--env WSL_DISTRO_NAME="${WSL_DISTRO_NAME}" \
--env WSL_INTEROP="${WSL_INTEROP}" \
--env WT_PROFILE_ID="${WT_PROFILE_ID}" \
--env WT_SESSION="${WT_SESSION}" \
ubuntu \
sh -c '/mnt/c/Windows/system32/notepad.exe'
Interestingly, I also see that bash -c '/mnt/c/Windows/system32/notepad.exe' fails in the same way, even though sh -c '/mnt/c/Windows/system32/notepad.exe' works just fine. I can also make a script with the contents of:
#!/bin/bash
/mnt/c/Windows/system32/notepad.exe "$@"
and run that instead of a shell, and it works as expected.
What's going on here? Can anybody help me out with a workaround?
Expected Behavior
In all cases, notepad should launch identically.
Actual Behavior
Launching notepad.exe from sh/dash works, as does putting it in a shell-script that runs under bash. Launching it directly fails, as does launching it from bash (even though that works when placed in a script).
All failures produce this message on stderr:
<3>WSL (1) ERROR: ConfigInitializeEntry:1621: Failed to mount (null) at /dev as devtmpfs 1
Diagnostic Logs
I couldn't think of any useful dianostic logs. Let me know if there's anything specific that you'd like to see.
Activity
github-actions commentedon Dec 6, 2023
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Open similar issues:
host.docker.internal(#6364), similarity score: 0.85Closed similar issues:
OneBlue commentedon Dec 7, 2023
/logs
nrclark commentedon Dec 8, 2023
Logfiles are attached here. During recording, I captured one successful launch (asking Docker to run
sh -c '/mnt/c/Windows/system32/notepad.exe') and one failed launch (asking Docker to run/mnt/c/Windows/system32directly) WslLogs-2023-12-08_00-30-10.zipOneBlue commentedon Dec 8, 2023
Thank you nrclark. The issue is that the executable that runs windows executables has special logic when its pid is 1, and inside a docker container it will behave that if it's the first process.
This is a bug, but until it's fixed you can work around it like this:
nrclark commentedon Dec 9, 2023
Thanks Blue (@OneBlue). I also noticed something else that might be related. When I have
systemdenabled inwsl.conf, I can't run Windows processes from inside of Docker at all. Running this:gives me a different error than before. Instead of that
/deverror, I get this interesting one instead:Note that if I run
sh -c 'ls /mnt/c/Windows/system32/notepad.exe'instead, the executable is -detected- OK, so it's definitely still getting mounted into my Docker container without issue.This error occurs when:
Systemd is enabled and running.
Docker is installed and active. It doesn't matter which Docker version I use (Ubuntu's packages or Docker.io's packages), or whether I run the service using
systemctl start dockeror manually usingservice docker start. When usingservice docker start, it also doesn't matter whether I do it from inside of a shell or whether I do it viawsl.exefrom Windows viacmd.exe.I try to run any Windows process from inside of a Docker image, even through methods that work when
systemdis disabled. This fails every time, with an stderr that it can't find the file. Note that I can see the file on the filesystem OK.I took a log capture of this happening and attached it to this ticket.
WslLogs-2023-12-08_22-14-56.zip
ndreys commentedon Dec 10, 2023
nrclark does adding
or equivalent
--mountincantation to yourdocker runhelp? I think I might have just had the pleasure of running into exactly the same issue and from what I can tell the problem is thatWSLInteropregisters/initas interpreter:but
/initisn't present in the container AKAENOENT/"file not found". Adding explicit bind-mount resolved the problem in my case.I could swear this used to work without, but now I'm starting to doubt my memory. 🤷
nrclark commentedon Dec 11, 2023
Andrey Smirnov (@ndreys) thanks for the pro-tip! You're right, that got .exe execution working under Docker when systemd is active. It's interesting that .exe execution works in non-systemd Docker without the explicit /init binding - maybe some more PID1 trickery.
The main issue in my ticket is still active though, and is unrelated to the secondary issue that Andrey Smirnov (@ndreys) addressed.
benhillis commentedon Jan 8, 2024
Fixed with https://github.com/microsoft/WSL/releases/tag/2.1.0
djc5166 commentedon Oct 24, 2025
Trying to understand what I am doing wrong here. Followed all of the above but my windows binaries always throw
<3>WSL (12 - ) ERROR: UtilBindVsockAnyPort:307: socket failed 38WSL version: 2.6.2.0
Kernel version: 6.6.87.2-1