Repository navigation
Open
Labels
area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-orchestratorwsl
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When trying to mount a path in the docker host under WSL, aspire tries to convert it to a windows path, and create the folder locally.
builder.WithAnnotation(new ContainerMountAnnotation("/var/run/docker.sock", "/var/run/docker.sock", ContainerMountType.BindMount, isReadOnly: true))
causes the folder C:\var\run\docker.sock to be created, although the mount is correct.
builder.WithContainerRuntimeArgs("-v /var/run/docker.sock:/var/run/docker.sock");
throws
could not create the container {"Container": {"name":"localstack-rrzzmnnz"}, "Reconciliation": 3, "error": "docker command 'CreateContainer' returned with non-zero exit code 1: command output: Stdout: '' Stderr: 'Error response from daemon: create /var/run/docker.sock: \" /var/run/docker.sock\" includes invalid characters for a local volume name, only \"[a-zA-Z0-9][a-zA-Z0-9_.-]\" are allowed. If you intended to pass a host directory, use absolute path\n'"}
and
builder.WithBindMount("/var/run/docker.sock", "/var/run/docker.sock", isReadOnly: true);
does not throw an error, but does not mount /var/run/docker.sock correctly.
Expected Behavior
No error is thrown, and /var/run/docker.sock is mounted from the docker host
Steps To Reproduce
In description
Exceptions (if any)
No response
.NET Version info
.NET SDK:
Version: 8.0.400
Commit: 36fe6dda56
Workload version: 8.0.400-manifests.56cd0383
MSBuild version: 17.11.3+0c8610977
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.400\
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[aspire]
Installation Source: VS 17.11.35219.272
Manifest Version: 8.1.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5
.NET SDKs installed:
8.0.400 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-orchestratorwsl
Activity
davidfowl commentedon Aug 22, 2024
Feels like this should be abstracted since we support multiple container runtimes. Maybe we can make this a more first class feature.
cc Karol Zadora-Przylecki (@karolz-ms)
karolz-ms commentedon Aug 26, 2024
Ross King (@rsking) first of all, are you running your program from within Windows OS, or from WSL subsystem? Are you using Docker Desktop, Podman, something else? And are you able to get the mount configured correctly by using Docker CLI directly? If so, please share the command.
Here is what I think is happening. If you are running your Aspire program from Windows, which seems like you do, I am not aware of a solution that would allow you to bind-mount the Docker socket from Windows host into your container. There simply is no "Docker socket" on the Windows host--e.g. Docker Desktop uses a named pipe instead https://docs.docker.com/desktop/faqs/general/#how-do-i-connect-to-the-remote-docker-engine-api and I do not think the bind mount syntax will work to proxy between Unix domain socket on the container side and a Windows named pipe on the Windows host side.
Your best bet is probably to run your Aspire program from within WSL subsystem, then
should work, assuming the Docker socked is available from within WSL subsystem.
David Negstad (@danegsta) please chime in if I confused something here.
rsking commentedon Aug 27, 2024
Karol Zadora-Przylecki (@karolz-ms) whilst I'm not a docker expert, these are my finings.
I am running on Windows, and have tried using both docker, and podman.
This is specifically to get LocalStack to operate correctly. It communicates with the docker API, via the socket.
when I run the command without the volume mount,
I get this debug message from
localstack.when mounting the socket directly
the error about not being able to get the server API version is gone
This indicates to me that the communication to the docker host (i.e. on the WSL machine) has been successful.
The idea is not to mount the windows docker, but rather the linux docker from WSL. Which seems to work when you specify a linux path.
rsking commentedon Aug 27, 2024
In my experimentation through
aspire, it seems to be making assumptions about the paths being passed in.with the command
it gets the full path to the file, which prepends the AppHost directory. this means that whilst the mount is successful, it mounts a file that doesn't work, as it mounts
C:\var\run\docker.sock. Aspire also tried to be helpful here by creating that folder.This leads to the docker API call in
localstackfailing with,I got around this by specifying the
ContainerMountAnnotationdirectly, which does pass through the mount correctly, but also creates a useless folder at/var/run/docker.sock, which is not actually mounted. This works, apart from the empty folder being created.I then thought the specifying the mount directly as
ContainerRunArgsshould get around this completely, but it appears likedcpctrlis doing something to those arguments. These are the same args that have worked when specifying this through the Docker CLI. This is the part that I have not been able to debug as to why this is occurring, as it seems to be occurring indcpctrl.rsking commentedon Aug 27, 2024
I have created a minimal repo at https://github.com/rsking/AspireDockerSock
karolz-ms commentedon Aug 27, 2024
OK this is all very helpful, thank you Ross King (@rsking). I think I know what is going on.
Looks like Docker Desktop is treating the host path
/var/run/docker.sockin a very special way. It allows to "bind mount" that path into the container even though it does not exist on the host machine at all; instead it silently creates a bind mount into Docker daemon VM. I am quite surprised that it works and I could not find anything about this special treatment in the Docker Desktop documentation, but it kind of makes sense.Aspire should probably special-case this mount source (
/var/run/docker.sock) as well. SpecificallyWithAnnotation()results in an unnecessaryC:\var\run\docker.sockfolder being created because Aspire (DCP specifically) is trying to be helpful and noticed that you are attempting a bind mount from a folder that does not exist on the machine. So it is trying to create that folder for you. We should stop doing that for/var/run/docker.sock.WithContainerRuntimeArgs()may not work simply because there should be two paramenters passed to it, that is, the way to call it isWithContainerRuntimeArgs("-v", "/var/run/docker.sock:/var/run/docker.sock"). Would appreciate a verification here; this should work.WithBindMount()does not work because Aspire is trying to compute the absolute path to/var/run/docker.sockand failing at that https://github.com/dotnet/aspire/blob/main/src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs#L80 We should not do this for/var/run/docker.socksource.rsking commentedon Aug 27, 2024
I can see the difference between
ContainerMountAnnotationandContainerRunArgsis in theContainerSpecclass, the former populates theVolumeMountcollection, and the later populates theRunArgscollection.rsking commentedon Aug 27, 2024
Ah! I can confirm that the
WithContainerRuntimeArgsdoes work when specifying with two arguments. I had incorrectly assumed that I would put in the exact string that I wanted to be supplied on the command line.karolz-ms commentedon Aug 27, 2024
Great, thanks for confirmation! That makes me more confident that the proposed fixes #5378 (comment) are the right call.
Thank you for submitting the issue and providing us with more information 🤗
rsking commentedon Aug 27, 2024
I'm not completely sure, but I think it is more of a case of docker through WSL treating windows paths differently. From what I understand, it more changes
C:\temp\whateverto/mnt/c/temp/whateverwhen it actually does the mount. When it sees a direct linux path, then it does not do the win->wsl path conversion. That is more from experience, rather than documentation,maddymontaquila commentedon May 14, 2026
Docker host path mapping under WSL was fixed in PR #9511 (
WithBindMountnow correctly handles the docker socket on WSL). Closing as fixed.davidfowl commentedon May 14, 2026
Reopening after a final strict review of the recent bulk closure. The associated change appears partial or does not fully satisfy the original issue, so this should remain open for normal triage.