docker VS代码无法通过开发容器运行容器

kxeu7u2r  于 2023-02-11  发布在  Docker
关注(0)|答案(1)|浏览(122)

我已经设置了一个. devcontainer.json文件,以便按照以下指南在容器内部进行开发:https://code.visualstudio.com/docs/devcontainers/containers#_create-a-devcontainerjson-file。
下面是json文件:

{
    "name": "myname Dev Container",
    
    "image": "myname/detectron2-pytorch:1.13.1-cuda11.6.2-cudnn8-devel",

    "runArgs": ["--gpus 0", "--cpuset-cpus 0-7", "--group-add phd", "--runtime=nvidia", "--shm-size=8G"],

    "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", "workspaceFolder": "/workspace"
}

但是,当我启动vscode命令“开发人员容器:在容器中重新打开”我收到以下日志的错误:

[2023-01-13T17:19:48.886Z] Dev Containers 0.266.1 in VS Code 1.74.3 

(97dec172d3256f8ca4bfb2143f3f76b503ca0534).
[2023-01-13T17:19:48.886Z] Start: Resolving Remote
[2023-01-13T17:19:48.990Z] Start: Run: ssh myIP /bin/sh
[2023-01-13T17:19:49.016Z] Start: Run in host: id -un
[2023-01-13T17:19:55.159Z] myname
[2023-01-13T17:19:55.159Z] 
[2023-01-13T17:19:55.159Z] Stop (6143 ms): Run in host: id -un
[2023-01-13T17:19:55.160Z] Start: Run in host: cat /etc/passwd
[2023-01-13T17:19:55.270Z] Stop (110 ms): Run in host: cat /etc/passwd
[2023-01-13T17:19:55.272Z] Start: Run in host: echo ~
[2023-01-13T17:19:55.409Z] /home/myname
[2023-01-13T17:19:55.410Z] 
[2023-01-13T17:19:55.411Z] Stop (139 ms): Run in host: echo ~
[2023-01-13T17:19:55.411Z] Start: Run in host: test -x '/home/myname/.vscode-remote-containers/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[2023-01-13T17:19:55.522Z] 
[2023-01-13T17:19:55.523Z] 
[2023-01-13T17:19:55.524Z] Exit code 1
[2023-01-13T17:19:55.525Z] Stop (114 ms): Run in host: test -x '/home/myname/.vscode-remote-containers/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[2023-01-13T17:19:55.527Z] Start: Run in host: test -x '/home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[2023-01-13T17:19:55.671Z] 
[2023-01-13T17:19:55.672Z] 
[2023-01-13T17:19:55.673Z] Stop (146 ms): Run in host: test -x '/home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[2023-01-13T17:19:55.674Z] Start: Run in host: test -f '/home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node_modules/node-pty/package.json'
[2023-01-13T17:19:55.745Z] 
[2023-01-13T17:19:55.746Z] 
[2023-01-13T17:19:55.746Z] Stop (72 ms): Run in host: test -f '/home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node_modules/node-pty/package.json'
[2023-01-13T17:19:55.746Z] Start: Run in host: test -f '/home/myname/.vscode-remote-containers/dist/vscode-remote-containers-server-0.266.1.js'
[2023-01-13T17:19:55.861Z] 
[2023-01-13T17:19:55.861Z] 
[2023-01-13T17:19:55.862Z] Stop (116 ms): Run in host: test -f '/home/myname/.vscode-remote-containers/dist/vscode-remote-containers-server-0.266.1.js'
[2023-01-13T17:19:55.944Z] userEnvProbe: loginInteractiveShell (default)
[2023-01-13T17:19:55.945Z] userEnvProbe shell: /bin/bash
[2023-01-13T17:19:56.192Z] userEnvProbe PATHs:
Probe:     '/home/myname/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
Container: None
[2023-01-13T17:19:56.290Z] Setting up container for folder or workspace: /home/myname/storage
[2023-01-13T17:19:56.291Z] Host: ssh://myIP
[2023-01-13T17:19:56.295Z] Start: Check Docker is running
[2023-01-13T17:19:56.296Z] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[2023-01-13T17:19:56.477Z] Stop (181 ms): Run in Host: docker version --format {{.Server.APIVersion}}
[2023-01-13T17:19:56.480Z] Server API version: 1.41
[2023-01-13T17:19:56.480Z] Stop (185 ms): Check Docker is running
[2023-01-13T17:19:56.485Z] Start: Run in Host: docker volume ls -q
[2023-01-13T17:19:56.713Z] Stop (228 ms): Run in Host: docker volume ls -q
[2023-01-13T17:19:57.107Z] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=/home/myname/storage --filter label=vsch.quality=stable
[2023-01-13T17:19:57.321Z] Stop (214 ms): Run in Host: docker ps -q -a --filter label=vsch.local.folder=/home/myname/storage --filter label=vsch.quality=stable
[2023-01-13T17:19:57.323Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:19:57.519Z] Stop (196 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:19:57.707Z] Start: Run in Host: /home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/myname/storage --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/myname/storage --log-level debug --log-format json --config /home/myname/storage/.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 true --terminal-columns 132 --terminal-rows 24
[2023-01-13T17:19:58.003Z] (node:826061) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[2023-01-13T17:19:58.004Z] (Use `node --trace-deprecation ...` to show where the warning was created)
[2023-01-13T17:19:45.231Z] @devcontainers/cli 0.25.2. Node.js v16.14.2. linux 5.4.0-125-generic x64.
[2023-01-13T17:19:45.231Z] Start: Run: docker buildx version
[2023-01-13T17:19:45.358Z] Stop (127 ms): Run: docker buildx version
[2023-01-13T17:19:45.359Z] github.com/docker/buildx v0.8.2-docker 6224def4dd2c3d347eee19db595348c50d7cb491
[2023-01-13T17:19:45.360Z] 
[2023-01-13T17:19:45.360Z] Start: Resolving Remote
[2023-01-13T17:19:45.369Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:19:45.416Z] Stop (47 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:19:45.418Z] Start: Run: docker inspect --type image myname/detectron2-pytorch:1.13.1-cuda11.6.2-cudnn8-devel
[2023-01-13T17:19:45.454Z] Stop (36 ms): Run: docker inspect --type image myname/detectron2-pytorch:1.13.1-cuda11.6.2-cudnn8-devel
[2023-01-13T17:19:45.457Z] local container features stored at: /home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/node_modules/vscode-dev-containers/container-features
[2023-01-13T17:19:45.460Z] Start: Run: tar --no-same-owner -x -f -
[2023-01-13T17:19:45.494Z] Stop (34 ms): Run: tar --no-same-owner -x -f -
[2023-01-13T17:19:45.498Z] Start: Run: docker build -f /tmp/devcontainercli-myname/updateUID.Dockerfile-0.25.2 -t vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid --build-arg BASE_IMAGE=myname/detectron2-pytorch:1.13.1-cuda11.6.2-cudnn8-devel --build-arg REMOTE_USER=myname --build-arg NEW_UID=5011 --build-arg NEW_GID=5011 --build-arg IMAGE_USER=myname /tmp/devcontainercli-myname/empty-folder
[2023-01-13T17:19:45.543Z] Sending build context to Docker daemon  2.607kB

[2023-01-13T17:19:45.607Z] Step 1/10 : ARG BASE_IMAGE
Step 2/10 : FROM $BASE_IMAGE
[2023-01-13T17:19:45.608Z]  ---> e69ecc2ff52e
Step 3/10 : USER root
[2023-01-13T17:19:46.340Z]  ---> Running in 6d92ac3eb4e6
[2023-01-13T17:19:47.199Z] Removing intermediate container 6d92ac3eb4e6
 ---> ebaa8cbcf651
Step 4/10 : ARG REMOTE_USER
[2023-01-13T17:19:48.107Z]  ---> Running in d9a1eb3d91af
[2023-01-13T17:19:48.778Z] Removing intermediate container d9a1eb3d91af
 ---> d05ba4b4208d
Step 5/10 : ARG NEW_UID
[2023-01-13T17:19:49.413Z]  ---> Running in 96f693f38802
[2023-01-13T17:19:50.273Z] Removing intermediate container 96f693f38802
 ---> 227c94fe6b54
Step 6/10 : ARG NEW_GID
[2023-01-13T17:19:50.908Z]  ---> Running in daab921dd086
[2023-01-13T17:19:51.545Z] Removing intermediate container daab921dd086
 ---> 68aecda6e7f5
Step 7/10 : SHELL ["/bin/sh", "-c"]
[2023-01-13T17:19:52.245Z]  ---> Running in f042926619f7
[2023-01-13T17:19:52.823Z] Removing intermediate container f042926619f7
 ---> 8693f7f14c8a
Step 8/10 : RUN eval $(sed -n "s/${REMOTE_USER}:[^:]*:\([^:]*\):\([^:]*\):[^:]*:\([^:]*\).*/OLD_UID=\1;OLD_GID=\2;HOME_FOLDER=\3/p" /etc/passwd);   eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_UID}:.*/EXISTING_USER=\1/p" /etc/passwd);    eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_GID}:.*/EXISTING_GROUP=\1/p" /etc/group);    if [ -z "$OLD_UID" ]; then      echo "Remote user not found in /etc/passwd ($REMOTE_USER).";    elif [ "$OLD_UID" = "$NEW_UID" -a "$OLD_GID" = "$NEW_GID" ]; then       echo "UIDs and GIDs are the same ($NEW_UID:$NEW_GID).";     elif [ "$OLD_UID" != "$NEW_UID" -a -n "$EXISTING_USER" ]; then      echo "User with UID exists ($EXISTING_USER=$NEW_UID).";     elif [ "$OLD_GID" != "$NEW_GID" -a -n "$EXISTING_GROUP" ]; then         echo "Group with GID exists ($EXISTING_GROUP=$NEW_GID).";   else        echo "Updating UID:GID from $OLD_UID:$OLD_GID to $NEW_UID:$NEW_GID.";       sed -i -e "s/\(${REMOTE_USER}:[^:]*:\)[^:]*:[^:]*/\1${NEW_UID}:${NEW_GID}/" /etc/passwd;        if [ "$OLD_GID" != "$NEW_GID" ]; then           sed -i -e "s/\([^:]*:[^:]*:\)${OLD_GID}:/\1${NEW_GID}:/" /etc/group;        fi;         chown -R $NEW_UID:$NEW_GID $HOME_FOLDER;    fi;
[2023-01-13T17:19:53.625Z]  ---> Running in b38cf8ca93d7
[2023-01-13T17:19:54.441Z] UIDs and GIDs are the same (5011:5011).
[2023-01-13T17:19:55.969Z] Removing intermediate container b38cf8ca93d7
 ---> 0062cf09266b
Step 9/10 : ARG IMAGE_USER
[2023-01-13T17:19:56.715Z]  ---> Running in c60dc827181d
[2023-01-13T17:19:57.352Z] Removing intermediate container c60dc827181d
 ---> c0504cc7a273
Step 10/10 : USER $IMAGE_USER
[2023-01-13T17:19:58.004Z]  ---> Running in b1d5a83992d1
[2023-01-13T17:19:58.606Z] Removing intermediate container b1d5a83992d1
 ---> c47e196e3bf9
Successfully built c47e196e3bf9
[2023-01-13T17:19:58.665Z] Successfully tagged vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid:latest
[2023-01-13T17:19:58.670Z] Stop (13172 ms): Run: docker build -f /tmp/devcontainercli-myname/updateUID.Dockerfile-0.25.2 -t vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid --build-arg BASE_IMAGE=myname/detectron2-pytorch:1.13.1-cuda11.6.2-cudnn8-devel --build-arg REMOTE_USER=myname --build-arg NEW_UID=5011 --build-arg NEW_GID=5011 --build-arg IMAGE_USER=myname /tmp/devcontainercli-myname/empty-folder
[2023-01-13T17:19:58.673Z] Start: Run: docker -v
[2023-01-13T17:19:58.724Z] Stop (51 ms): Run: docker -v
[2023-01-13T17:19:58.724Z] Start: Run: docker events --format {{json .}} --filter event=start
[2023-01-13T17:19:58.730Z] Start: Starting container
[2023-01-13T17:19:58.730Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/myname/storage,target=/workspace,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/home/myname/storage --gpus 0 --cpuset-cpus 0-7 --group-add phd --runtime=nvidia --shm-size=8G --entrypoint /bin/sh -l devcontainer.metadata=[] vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid -c echo Container started
[2023-01-13T17:19:58.865Z] unknown flag: --gpus 0
See 'docker run --help'.
[2023-01-13T17:19:58.870Z] Stop (140 ms): Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/myname/storage,target=/workspace,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/home/myname/storage --gpus 0 --cpuset-cpus 0-7 --group-add phd --runtime=nvidia --shm-size=8G --entrypoint /bin/sh -l devcontainer.metadata=[] vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid -c echo Container started
[2023-01-13T17:19:58.871Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:19:58.877Z] Stop (153 ms): Run: docker events --format {{json .}} --filter event=start
[2023-01-13T17:19:58.917Z] Stop (46 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/myname/storage
[2023-01-13T17:20:11.681Z] Error: Command failed: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/home/myname/storage,target=/workspace,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=/home/myname/storage --gpus 0 --cpuset-cpus 0-7 --group-add phd --runtime=nvidia --shm-size=8G --entrypoint /bin/sh -l devcontainer.metadata=[] vsc-storage-8e1b4f7709db0f1caaf544a1f086b68b-uid -c echo Container started
[2023-01-13T17:20:11.682Z] trap "exit 0" 15
[2023-01-13T17:20:11.682Z] exec "$@"
[2023-01-13T17:20:11.682Z] while sleep 1 & wait $!; do :; done -
[2023-01-13T17:20:11.682Z]     at Aoe (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1893:1355)
[2023-01-13T17:20:11.682Z]     at uT (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1893:1291)
[2023-01-13T17:20:11.683Z]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-01-13T17:20:11.685Z]     at async Poe (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1899:2128)
[2023-01-13T17:20:11.688Z]     at async Zf (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1899:3278)
[2023-01-13T17:20:11.689Z]     at async aue (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:2020:15276)
[2023-01-13T17:20:11.690Z]     at async oue (/home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:2020:15030)
[2023-01-13T17:20:11.704Z] Stop (13997 ms): Run in Host: /home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/myname/storage --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/myname/storage --log-level debug --log-format json --config /home/myname/storage/.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 true --terminal-columns 132 --terminal-rows 24
[2023-01-13T17:20:11.706Z] Exit code 1
[2023-01-13T17:20:11.716Z] Command failed: /home/myname/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/myname/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/myname/storage --workspace-mount-consistency cached --id-label devcontainer.local_folder=/home/myname/storage --log-level debug --log-format json --config /home/myname/storage/.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 true --terminal-columns 132 --terminal-rows 24
[2023-01-13T17:20:11.716Z] Exit code 1

“docker run”命令失败,同时显示“未知标志:--gpus 0”。但是如果我删除“--gpus”选项,那么它会显示“未知标志:--cpuset-cpus 0-7”。我不明白为什么,因为如果我直接从终端运行同样的“docker run”命令,它就能完全正常工作。

pjngdqdw

pjngdqdw1#

我遇到了同样的问题。我用命令"runArgs": ["--gpus", "all"]代替"runArgs": ["--gpus all"]来修复它。标志和参数需要是一个自己的字符串。

相关问题