-
Notifications
You must be signed in to change notification settings - Fork 695
Allow mounting the docker socket using WithBindMount #9511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: davidfowl <[email protected]>
tests/Aspire.Hosting.Containers.Tests/DockerSocketBindMountTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: davidfowl <[email protected]>
Co-authored-by: davidfowl <[email protected]>
Co-authored-by: davidfowl <[email protected]>
Co-authored-by: davidfowl <[email protected]>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
||
var annotation = new ContainerMountAnnotation(Path.GetFullPath(source, builder.ApplicationBuilder.AppHostDirectory), target, ContainerMountType.BindMount, isReadOnly); | ||
// If the source starts with '/', it's a Linux-style rooted path, so we use it directly without resolution | ||
var sourcePath = source.StartsWith('/') ? source : Path.GetFullPath(source, builder.ApplicationBuilder.AppHostDirectory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "starts with /", should this check if the path is already rooted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use Path.IsPathRooted()
instead of checking StartsWith('/')
. This is more robust as it properly handles absolute paths on different operating systems. The change was implemented in 3ed3296.
Co-authored-by: eerhardt <[email protected]>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Changes
This PR addresses the need to mount
/var/run/docker.sock
into containers, enabling Docker-in-Docker scenarios. Two main changes were made:Modified the
WithBindMount
method to special-case Linux-style absolute paths (those starting with/
):/
are now passed through directly without attempting to resolve them relative to the AppHost directoryAdded a new convenience extension method
WithDockerSocketBindMount()
that:/var/run/docker.sock
to/var/run/docker.sock
in the containerTests Added
ContainerMountAnnotation
that verifies it accepts/var/run/docker.sock
as a valid bind mount sourceWithBindMount
that verifies it correctly handles Docker socket pathsWithDockerSocketBindMount
method to verify it creates the correct annotationDockerSocketBindMountTests.cs
to verify the Docker socket binding works correctlyBefore this change, users could not easily mount the Docker socket into containers when specifying Linux paths on Windows hosts, as the code would incorrectly try to resolve
/var/run/docker.sock
as a relative path.Fixes #7077.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
0t3vsblobprodcus362.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)7devsblobprodcus323.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)7k6vsblobprodcus337.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)cdn.fwupd.org
dlbvsblobprodcus316.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)h6tvsblobprodcus346.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)i1qvsblobprodcus353.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)imzvsblobprodcus368.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)jd4vsblobprodcus366.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)kh4vsblobprodcus325.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)l49vsblobprodcus358.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)ofvvsblobprodcus315.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)p2ovsblobprodcus312.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)pe4vsblobprodcus351.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)x3yvsblobprodcus370.vsblob.vsassets.io
/home/REDACTED/work/aspire/aspire/.dotnet/dotnet test tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.