Skip to content

Docker bound volume mounts resolve to OS local path #993

Closed

Description

@r0ss88

Encountering an issue when attempting to create a container which includes a bind typed volume mount.

The problem is internally, the path is resolved as the local OS system. This is fine when docker is also running locally, however, when accessing a separate Docker context from WSL, the path is incorrect.

Even when providing an absolute path, the path is resolved to a Windows path.

For example, say we create a container with a single volume mount:

var resource = new ContainerResource(name);

builder.AddResource(resource)
            .WithVolumeMount("/etc/container-test", $"/app/{name}", VolumeMountType.Named)
            .WithAnnotation(new ContainerImageAnnotation { Image = "some-image", Tag = "latest" });

The path specified at "/etc/container-test" ends up being resolved to: "C:\project-directory\etc\container-test".

Problematic code is located here:

https://github.com/dotnet/aspire/blob/69937e218b7dd8fd03f2b7e92ecdad3fcd4fbc8a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs#L476

My proposal would be to check if the path is rooted (Path.IsPathRooted) before calling Path.GetFullPath. This should continue to work cross platform (whilst accessing a subsystem like in this case).

Activity

  1. ghost added
    area-app-model
    on Nov 22, 2023
  2. davidfowl commented on Nov 22, 2023

    @davidfowl
    Collaborator

    Send a PR?

  3. r0ss88 commented on Nov 22, 2023

    @r0ss88
    ContributorAuthor

    David Fowler (@davidfowl) thank you for responding so quickly!

    #997

  4. BrennanConroy commented on Jan 22, 2024

    @BrennanConroy
    Member

    Done via #997

  5. locked and limited conversation to collaborators on Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-app-model

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions