Skip to content
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

Can't Bind Mount Host Folder Using docker-outside-of-docker #919

Open
leobaldoneto opened this issue Mar 25, 2024 · 6 comments
Open

Can't Bind Mount Host Folder Using docker-outside-of-docker #919

leobaldoneto opened this issue Mar 25, 2024 · 6 comments

Comments

@leobaldoneto
Copy link
Contributor

leobaldoneto commented Mar 25, 2024

Hi, I created a container from inside a dev container using the docker-outside-of-docker feature. I mapped an bind mount to the host repo folder. However, the files don't appear in the bound folder inside the container.

Minimum configuration to reproduce:

.devcontainer/devcontainer.json

{
	"image": "mcr.microsoft.com/devcontainers/base:bullseye",
	"features": {
		"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
	},
	"remoteEnv": {
		"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
	}
}

STEPS:

  • Build and connect to the dev container.
  • Run the command: docker run -it --rm -v ${LOCAL_WORKSPACE_FOLDER}:/workspace debian bash

BEHAVIOR:

  • Can't see any files inside container folder /workspace

EXPECTED BEHAVIOR:

  • See files from local workspace folder inside container at /workspace

ADDITIONAL INFO:

  • Host: Windows 11 with Docker powered by WSL 2 with Ubuntu 22.
  • Docker version: 25.0.3
@superheikie
Copy link

I am having this problem as well.

@myrddraall
Copy link

myrddraall commented Mar 26, 2024

This just started happening to us as well. It seems the dev container has lost a mapping somewhere and host paths are no longer valid. If I hard code the volume path that was in the env var then it won't work in the dev container but will work on the wsl host.
The only difference I'm seeing is that we get an error that the bind path cannot be found rather than an empty folder

${LOCAL_WORKSPACE_FOLDER}/app - fails in dev container, fails in wsl because the env var doesn't exist
/home/user/dev/app - fails in dev container - works in wsl
\\\\wsl.localhost\\Ubuntu-20.04\\home/user/dev/app -works in both

As a workaround i changed the devcontainer.json

{
    ...
    "containerEnv": {
        "LOCAL_WORKSPACE_FOLDER": "\\\\wsl.localhost\\${localEnv:WSL_DISTRO_NAME}\\${localWorkspaceFolder}"
    }
}

@leobaldoneto
Copy link
Contributor Author

This just started happening to us as well. It seems the dev container has lost a mapping somewhere and host paths are no longer valid. If I hard code the volume path that was in the env var then it won't work in the dev container but will work on the wsl host.
The only difference I'm seeing is that we get an error that the bind path cannot be found rather than an empty folder

${LOCAL_WORKSPACE_FOLDER}/app - fails in dev container, fails in wsl because the env var doesn't exist
/home/user/dev/app - fails in dev container - works in wsl
\\\\wsl.localhost\\Ubuntu-20.04\\home/user/dev/app -works in both

As a workaround i changed the devcontainer.json

{
    ...
    "containerEnv": {
        "LOCAL_WORKSPACE_FOLDER": "\\\\wsl.localhost\\${localEnv:WSL_DISTRO_NAME}\\${localWorkspaceFolder}"
    }
}

It worked for me has an workaround. thanks!

@samruddhikhandale
Copy link
Member

Thanks for the details. @gauravsaini04 Can you help investigate this issue? Thanks!

@samruddhikhandale
Copy link
Member

@chrmarti Any thoughts on this issue?

From microsoft/vscode-remote-release#3588 (comment) it seemed like it wasn't possible before. However, moby/moby#32582 seems to have merged-in recently.

Do we need any changes on our end?

@chrmarti
Copy link

This works for me with Docker Desktop 4.30 (Docker Engine 26.1.1). Variations I have tried (all worked):

  • Local workspace folder on Windows filesystem.
  • Local workspace folder on WSL filesystem.
  • Local workspace folder on Windows filesystem and Dev Containers: Execute in WSL enabled in settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants