我一直在一个开发者容器中进行C++开发,我重新构建了这个容器,但是它无法构建。从那以后,我尝试了另一个容器,它也不会构建。我知道devcontainer文件和dockerfile与此操作时没有任何变化。
当我第一次注意到,我打开了另一个类似的回购容器-它启动容器罚款。当我试图重建它时,我也得到了同样的错误。
第一个错误是
错误:未能解决: rpc错误:代码=未知desc =未能解决与前端dockerfile.v0:未能解决与前端gateway.v0: rpc错误:代码=未知desc =目标阶段dev_containers_target_stage无法找到
在上下文中
=> CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b 0.0s
[2022-10-07T21:44:13.502Z] [+] Building 1.8s (7/7) FINISHED
=> [internal] load build definition from Dockerfile-with-features 0.0s
=> => transferring dockerfile: 1.12kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> resolve image config for docker.io/docker/dockerfile:1.4 1.5s
[2022-10-07T21:44:13.502Z] => [auth] docker/dockerfile:pull token for registry-1.docker.io 0.0s
=> CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b 0.0s
=> [internal] load build definition from Dockerfile-with-features 0.0s
=> [internal] load .dockerignore 0.0s
ERROR: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = target stage dev_containers_target_stage could not be found
[2022-10-07T21:44:13.511Z] Stop (2075 ms): Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-david/container-features/0.19.0-1665179051412/Dockerfile-with-features -t vsc-components-e3528559c8b219e2efe0f837299d4fa8 --target dev_containers_target_stage --build-context dev_containers_feature_content_source=/tmp/devcontainercli-david/container-features/0.19.0-1665179051412 --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 /home/david/Repos/Arabica/Components/.devcontainer
[2022-10-07T21:44:13.512Z] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-david/container-features/0.19.0-1665179051412/Dockerfile-with-features -t vsc-components-e3528559c8b219e2efe0f837299d4fa8 --target dev_containers_target_stage --build-context dev_containers_feature_content_source=/tmp/devcontainercli-david/container-features/0.19.0-1665179051412 --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 /home/david/Repos/Arabica/Components/.devcontainer
[2022-10-07T21:44:13.512Z] at fD (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:298:1633)
[2022-10-07T21:44:13.513Z] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-10-07T21:44:13.513Z] at async wd (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:297:1958)
[2022-10-07T21:44:13.513Z] at async sC (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:297:894)
[2022-10-07T21:44:13.513Z] at async bD (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:303:2020)
[2022-10-07T21:44:13.513Z] at async ys (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:303:3182)
[2022-10-07T21:44:13.513Z] at async UL (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:423:10319)
[2022-10-07T21:44:13.513Z] at async ML (/home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js:423:10075)
[2022-10-07T21:44:13.515Z] Stop (3813 ms): Run in Host: /home/david/.vscode-server/bin/64bbfbf67ada9953918d72e1df2f4d8e537d340e/node /home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/david/Repos/Arabica/Components --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu\home\david\Repos\Arabica\Components --log-level debug --log-format json --config /home/david/Repos/Arabica/Components/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2022-10-07T21:44:13.515Z] Exit code 1
[2022-10-07T21:44:13.518Z] Command failed: /home/david/.vscode-server/bin/64bbfbf67ada9953918d72e1df2f4d8e537d340e/node /home/david/.vscode-remote-containers/dist/dev-containers-cli-0.255.2/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/david/Repos/Arabica/Components --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu\home\david\Repos\Arabica\Components --log-level debug --log-format json --config /home/david/Repos/Arabica/Components/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2022-10-07T21:44:13.518Z] Exit code 1
作为参考,dev容器是
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp
{
"name": "Components",
"build": {
"dockerfile": "Dockerfile"
},
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace/Components",
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools-themes",
"ms-vscode.makefile-tools",
"jeff-hykin.better-cpp-syntax",
"bneumann.cpputest-test-adapter"
]
}
},
// Use 'postCreateCommand' to run commands after the container is created. "postStartCommand": "git config --global core.sshCommand /usr/bin/ssh",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
Dockerfile
FROM davidcozens/cpputest:4
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
到目前为止,我已经尝试过:清除码头缓存的图像和清理集装箱。我在wsl2上更新了我的ubuntu发行版,我确保了码头是最新的。我更新了windows --我正在运行windows 11的最新版本。
发布于 2022-10-31 04:09:24
问题是Dockerfile
的最后一行
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
Docker以前可能在Dockerfile
RUN
语句中支持最后一个尾随斜杠,但它似乎不再受支持。(我不知道这是什么时候发生的,但我在Docker 20.10.21上,它不再受支持。)
这个尾随斜杠似乎干扰了VS代码生成的FROM
文件中的以下Dockerfile-with-features
语句,该文件如下所示:
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage
如果不能再读取该FROM
语句,那么错误消息就更有意义了:
无法找到
目标阶段dev_containers_target_stage
移除Dockerfile
中的尾随Dockerfile
,它应该可以工作。
https://stackoverflow.com/questions/73993058
复制相似问题