Can't build dev container on D:
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 1
Looks 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.
Is there a known workaround for that? Also we observe it on C: drive 😢
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
unable to prepare context: unable to get relative Dockerfile path: Rel: can't make C:\Users\<redacted>\AppData\Local\Temp\devcontainercli\container-features\0.23.2-1667553015190\Dockerfile-with-features relative to \\?\c:\Users\<redacted>\Desktop\php\.devcontainer
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