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

The error of failing to build an image and container using a Dockerfile in VS Code; the same Dockerfile content worked before. #9834

Closed
AlexYangGitHub opened this issue Apr 25, 2024 · 10 comments
Assignees
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@AlexYangGitHub
Copy link

[9101 ms] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /var/folders/_5/kxgshz757k9f6zk8jmdkdvz00000gn/T/devcontainercli/container-features/0.58.0-1714082052132/Dockerfile-with-features -t vsc-readingproject-fecfab0f449ba1d49dd05429d5576c325e4aa0ac5e807dcd86d3940fb7b9884a --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/configs/ReadingProject
[+] Building 3.6s (7/9)
=> [internal] load build definition from Dockerfile-with-features 0.0s
=> => transferring dockerfile: 806B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9-slim-buster 3.4s
=> [dev_container_auto_added_stage_label 1/5] FROM docker.io/library/pyt 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 201B 0.0s
=> CACHED [dev_container_auto_added_stage_label 2/5] WORKDIR /app 0.0s
=> ERROR [dev_container_auto_added_stage_label 3/5] COPY requirements.tx 0.0s

[dev_container_auto_added_stage_label 3/5] COPY requirements.txt .:


ERROR: failed to solve: failed to compute cache key: "/requirements.txt" not found: not found
[13922 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /var/folders/_5/kxgshz757k9f6zk8jmdkdvz00000gn/T/devcontainercli/container-features/0.58.0-1714082052132/Dockerfile-with-features -t vsc-readingproject-fecfab0f449ba1d49dd05429d5576c325e4aa0ac5e807dcd86d3940fb7b9884a --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/configs/ReadingProject
[13923 ms] at ptA (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:465:1933)
[13923 ms] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[13923 ms] at async Pm (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:464:1841)
[13923 ms] at async kH (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:464:610)
[13923 ms] at async UtA (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:481:3692)
[13923 ms] at async $C (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:481:4807)
[13923 ms] at async QrA (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:661:13255)
[13924 ms] at async urA (/Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js:661:12996)
[13940 ms] Exit code 1
[13949 ms] Command failed: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/Alex/.vscode/extensions/ms-vscode-remote.remote-containers-0.354.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-0f3df60c-a104-41c5-aa3a-6569cd46b0b31714082040830 --workspace-folder /Users/Alex/Documents/2024/ReadingProject --workspace-mount-consistency cached --id-label devcontainer.local_folder=/Users/Alex/Documents/2024/ReadingProject --id-label devcontainer.config_file=/Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/configs/ReadingProject/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/configs/ReadingProject/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[13949 ms] Exit code 1

@AlexYangGitHub AlexYangGitHub changed the title VS Code 中使用 Dockerfile 建立 image & container 錯誤; 一樣的 Dockerfile 內容,之前是可以成功建立 The error of failing to build an image and container using a Dockerfile in VS Code; the same Dockerfile content worked before. Apr 26, 2024
@AlexYangGitHub
Copy link
Author

@chrmarti
The same Dockerfile, I can build image via cmd successfully, so only problem occurs in VS code.

@AlexYangGitHub
Copy link
Author

no follow up ?

@chrmarti
Copy link
Contributor

The context is set to /Users/Alex/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/configs/ReadingProject. Does that folder contain a requirements.txt?

@chrmarti chrmarti transferred this issue from microsoft/vscode Apr 30, 2024
@chrmarti chrmarti added containers Issue in vscode-remote containers info-needed Issue requires more information from poster labels Apr 30, 2024
@AlexYangGitHub
Copy link
Author

AlexYangGitHub commented Apr 30, 2024

Absolutely yes.

Error message from above "=> ERROR [dev_container_auto_added_stage_label 3/5] COPY requirements.tx 0.0s".
that file name is "requirements.tx" , not my file name "requirements.txt".
I try it at window10 and macOS, got the same result.

@AlexYangGitHub
Copy link
Author

image
@chrmarti I just have the 3 simple files, and want to create image and container via VSCode,which worked well before, but now just have problem with.

Reading_2.zip

@AlexYangGitHub
Copy link
Author

AlexYangGitHub commented Apr 30, 2024

Win10:
Version: 1.88.1 (user setup)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:41:02.734Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.19045

and MacOS
image

@chrmarti
Copy link
Contributor

The zip file you attached does not have a devcontainer.json, are these files not in the same location? Maybe you are using a workspace folder with the requirements.txt and a separate user-data-dir folder for the devcontainer.json?

@AlexYangGitHub
Copy link
Author

Yes, my devcontainer.json is in different dir.
After VScode creates devcontainer.json in the same dir, problem is solved.
Thanks.

But why previous version of VSCode did not have this problem ?

@chrmarti
Copy link
Contributor

chrmarti commented May 2, 2024

The COPY source path in the Dockerfile is relative to the context folder. Maybe you changed the context folder in the devcontainer.json? When there is no context folder specified, the Dockerfile's folder is used as the default.

@AlexYangGitHub
Copy link
Author

ok, thanks you @chrmarti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants