Repository navigation
Can't build dev container on D: #240
Copy link
Copy link
Open
Description
If Dockerfile and devcontainer.json in D: drive on Windows (that is D:\.devcontainer\Dockerfile & D:\.devcontainer\devcontainer.json)
D:\.devcontainer\Dockerfile
ARG VARIANT="bullseye"
FROM mcr.microsoft.com/devcontainers/rust:1-${VARIANT}D:\.devcontainer\devcontainer.json
{
"name": "Sample",
"build": {
"dockerfile": "Dockerfile"
}
}Build container with devcontainer will fail:
# in D:\
devcontainer build .
[18 ms] @devcontainers/cli 0.20.0. Node.js v16.14.2. win32 10.0.22621 x64.
[797 ms] Start: Run: docker build -t dev_container_feature_content_temp -f C:\Users\USER\AppData\Local\Temp\devcontainercli\container-features\0.20.0-1666419425720\Dockerfile.buildContent C:\Users\USER\AppData\Local\Temp\devcontainercli\container-features\0.20.0-1666419425720
[975 ms] Sending build context to Docker daemon 297kB
[1007 ms] Step 1/2 : FROM scratch
--->
Step 2/2 : COPY . /tmp/build-features/
[1007 ms]
[1013 ms] ---> Using cache
[1014 ms] ---> 65d7fa21086a
[1014 ms] Successfully built 65d7fa21086a
[1022 ms] Successfully tagged dev_container_feature_content_temp:latest
[1022 ms] SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
[1027 ms] Start: Run: docker build -f C:\Users\USER\AppData\Local\Temp\devcontainercli\container-features\0.20.0-1666419425720\Dockerfile-with-features -t vsc-vscode-remote-try-rust-2b487e416576759e13404c2a21fd7848 --target dev_containers_target_stage --build-arg VARIANT=bullseye --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp D:\.devcontainer
[1122 ms] unable to prepare context: unable to get relative Dockerfile path: Rel: can't make C:\Users\USER\AppData\Local\Temp\devcontainercli\container-features\0.20.0-1666419425720\Dockerfile-with-features relative to E:\.devcontainer
[1125 ms] Exit code 1Looks like filepath.Rel (https://github.com/docker/cli/blob/v20.10.20/cli/command/image/build/context.go#L358) in docker-cli will fail due to devcontainer create Dockerfile-with-features in system drive regardless original workspace.
The devcontainer should create temp files in same drive as workspace instead of just creating in Windows temp.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
[-]Build failed on Windows[/-][+]Can't build dev container on D:[/+]unique-dominik commentedon Nov 1, 2022
Is there a known workaround for that? Also we observe it on
C:drive 😢nurdism commentedon Nov 4, 2022
Is there a way to downgrade or workaround this issue? I am unable to rebuild my image and can not get into my dev environment, this is not limited to just the
D:drive. My devcontainer/docker service is on a remote server using docker context to communicate remotely.I am getting
vidhya03 commentedon Jan 9, 2023
I am also facing the same , in windows I have set virtual drive as V: => c:\myfiles\
docker build -f C:\Users<user>\AppData\Local\Temp\devcontainercli\container-features\0.25.2-1673283658137\Dockerfile-with-features -t vsc-project-f9af19950fe987d4e0a42ac4a1093111 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp v:\esag_github\project.devcontainer
unable to prepare context: unable to get relative Dockerfile path: Rel: can't make C:\Users<user>\AppData\Local\Temp\devcontainercli\container-features\0.25.2-1673283658137\Dockerfile-with-features relative to V:\esag_github\project.devcontainer
Zeratoxx commentedon Oct 5, 2024
I encountered this issue today.
xuanswe commentedon Feb 28, 2026
Hi, is there any progress on this issue?
Most people put files on D: drive and many people also need to connect to remote docker too.
kafumanto commentedon Mar 10, 2026
Same problem. It's really hard to believe this bug has been around since 2022.
kafumanto commentedon Mar 13, 2026
A workaround is to configure the
TEMPandTMPenvironment variables to a path on the same drive of the project (e.g. onD:\). You can do it in a local terminal session (ensuring to launchcodefrom the same session), for example: