microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.64k stars 285 forks source link

Error: Missing node-pty when using specific Dockerfile command #7356

Closed aleksanderostrup closed 1 year ago

aleksanderostrup commented 2 years ago

Steps to Reproduce:

  1. In the Dockerfile, using the command: RUN usermod -l ${USERNAME} vscode --home /home/${USERNAME} --move-home (where the ${USERNAME} is defined) breaks the building of the container. It has worked previously with version 0.224.3 of Dev Containers.

This might be related to https://github.com/microsoft/vscode-remote-release/issues/6525.

I have tried with the pre-release version of the extension, but that does not seem to fix the issue either.

For some reason I cannot upload my *.log file, so here is the crucial part:

=> => exporting layers                                                    0.0s
 => => writing image sha256:0f3755884b553f3689eaab4fa8052e26de742a7371bdb  0.0s
 => => naming to docker.io/library/vsc-p1linux-93c1819c338c289a0848996cea  0.0s
[2022-10-13T12:39:37.088Z] 
[2022-10-13T12:39:37.387Z] 
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
[2022-10-13T12:39:37.395Z] Stop (1137 ms): Run: docker build -f /tmp/devcontainercli-ale/updateUID.Dockerfile-0.20.0 -t vsc-p1linux-93c1819c338c289a0848996cea42d1ff-uid --build-arg BASE_IMAGE=vsc-p1linux-93c1819c338c289a0848996cea42d1ff --build-arg REMOTE_USER=vscode --build-arg NEW_UID=1000 --build-arg NEW_GID=1000 --build-arg IMAGE_USER=root /tmp/devcontainercli-ale/empty-folder
[2022-10-13T12:39:37.396Z] Start: Run: docker -v
[2022-10-13T12:39:37.453Z] Stop (57 ms): Run: docker -v
[2022-10-13T12:39:37.453Z] Start: Run: docker events --format {{json .}} --filter event=start
[2022-10-13T12:39:37.455Z] Start: Starting container
[2022-10-13T12:39:37.455Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/ale/git/p1linux,target=/workspaces/p1linux --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl$\Ubuntu-22.04\home\ale\git\p1linux --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --entrypoint /bin/sh vsc-p1linux-93c1819c338c289a0848996cea42d1ff-uid -c echo Container started
[2022-10-13T12:39:37.972Z] Container started
[2022-10-13T12:39:37.980Z] Stop (525 ms): Starting container
[2022-10-13T12:39:37.980Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu-22.04\home\ale\git\p1linux
[2022-10-13T12:39:38.046Z] Stop (66 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu-22.04\home\ale\git\p1linux
[2022-10-13T12:39:38.047Z] Start: Run: docker inspect --type container 35f38423901c
[2022-10-13T12:39:38.115Z] Stop (68 ms): Run: docker inspect --type container 35f38423901c
[2022-10-13T12:39:38.116Z] Start: Inspecting container
[2022-10-13T12:39:38.116Z] Start: Run: docker inspect --type container 35f38423901cda5a53086530f7d3c4b7b931d4996d7b139a05491ea67efc9342
[2022-10-13T12:39:38.184Z] Stop (68 ms): Run: docker inspect --type container 35f38423901cda5a53086530f7d3c4b7b931d4996d7b139a05491ea67efc9342
[2022-10-13T12:39:38.185Z] Stop (69 ms): Inspecting container
[2022-10-13T12:39:38.186Z] Start: Run in container: /bin/sh
[2022-10-13T12:39:38.189Z] Start: Run in container: uname -m
[2022-10-13T12:39:38.274Z] Stop (88 ms): Run in container: /bin/sh
[2022-10-13T12:39:38.276Z] Shell server terminated (code: 126, signal: null)
[2022-10-13T12:39:38.276Z] unable to find user vscode: no matching entries in passwd file

[2022-10-13T12:39:38.275Z] Start: Run in container: cat /etc/passwd
[2022-10-13T12:39:38.275Z] Stdin closed!
[2022-10-13T12:39:38.278Z] Error: An error occurred setting up the container.
[2022-10-13T12:39:38.278Z]     at Use (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1868:1339)
[2022-10-13T12:39:38.279Z]     at jO (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1868:1275)
[2022-10-13T12:39:38.279Z]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-10-13T12:39:38.279Z]     at async Xse (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1874:2030)
[2022-10-13T12:39:38.279Z]     at async Uf (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1874:3193)
[2022-10-13T12:39:38.279Z]     at async Cae (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1994:10350)
[2022-10-13T12:39:38.279Z]     at async yae (/home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js:1994:10104)
[2022-10-13T12:39:38.282Z] Stop (27317 ms): Run in Host: /home/ale/.vscode-remote-containers/bin/64bbfbf67ada9953918d72e1df2f4d8e537d340e/node /home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/ale/git/p1linux --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl$\Ubuntu-22.04\home\ale\git\p1linux --log-level debug --log-format json --config /home/ale/git/p1linux/.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-13T12:39:38.283Z] Exit code 1
[2022-10-13T12:39:38.287Z] Command failed: /home/ale/.vscode-remote-containers/bin/64bbfbf67ada9953918d72e1df2f4d8e537d340e/node /home/ale/.vscode-remote-containers/dist/dev-containers-cli-0.259.0/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/ale/git/p1linux --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl$\Ubuntu-22.04\home\ale\git\p1linux --log-level debug --log-format json --config /home/ale/git/p1linux/.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-13T12:39:38.288Z] Exit code 1
[2022-10-13T12:39:41.525Z] Start: Run: wsl -d Ubuntu-22.04 -e wslpath -u \\wsl$\Ubuntu-22.04\home\ale\git\p1linux
[2022-10-13T12:39:41.748Z] Stop (223 ms): Run: wsl -d Ubuntu-22.04 -e wslpath -u \\wsl$\Ubuntu-22.04\home\ale\git\p1linux
alexnfsc175 commented 2 years ago

using podman and podman-compose the same problem happens

[2022-10-17 23:51:10.464] [exthost] [error] {"message":"Command failed: /home/alex/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/node /home/alex/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-path podman --docker-compose-path podman-compose --workspace-folder /home/alex/development/test-api --log-level debug --log-format json --config /home/alex/development/test-api/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root true","code":1} remote-containers.openFolder {"value":"ms-vscode-remote.remote-containers","_lower":"ms-vscode-remote.remote-containers"}

running the command directly to understand the error, I have this output:

$ /home/alex/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/node /home/alex/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-path podman --docker-compose-path podman-compose --workspace-folder /home/alex/development/test-api --log-level debug --log-format json --config /home/alex/development/test-api/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root true
(node:19830) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Missing node-pty
    at gD (/home/alex/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js:1666:1412)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async un (/home/alex/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js:1665:13306)
    at async _ae (/home/alex/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js:1994:25824)
devcontainer.json ```jsonc // For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.112.0/containers/typescript-node-12 { "name": "My App", "dockerComposeFile": "docker-compose.dev-container.yml", "service": "app", "shutdownAction": "stopCompose", // Open the sub-folder with the source code "workspaceFolder": "/workspace", // Set *default* container specific settings.json values on container create. "settings": { "#terminal.integrated.defaultProfile.linux#": "/bin/bash" }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // Left empty because this is handled by docker-compose for individual services, // use this only for additional ports not needed by those services (e.g. ssh) "forwardPorts": [], // Install npm packages to the shared volume before running docker-compose in the container "postCreateCommand": "cd frontend && yarn install && cd ../backend && yarn install" } ```
docker-compose.dev-container.yml ```yml version: "3.8" services: app: build: context: .. dockerfile: .devcontainer/Dockerfile.dev init: true volumes: # Use a named volume for the source code - test-api:/workspace # Persist VS Code extensions between rebuilds - vscode-extensions:/root/.vscode-server/extensions # And/or for VS Code Insiders - vscode-extensions-insiders:/root/.vscode-server-insiders/extensions container_name: api-dev-container # Overrides default command so things don't shut down after the process ends. command: sleep infinity volumes: test-api: vscode-extensions: vscode-extensions-insiders: ```

Dockerfile.dev ```yml # [Choice] Node.js version: 14, 12, 10 ARG VARIANT=18-bullseye FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT} # Copy the full repository into the /workspace directory WORKDIR /workspace COPY . . ```
docker-init.sh ```bash #!/usr/bin/env bash npm start ```
podman system info ```bash $ podman system info host: arch: amd64 buildahVersion: 1.27.0 cgroupControllers: [] cgroupManager: cgroupfs cgroupVersion: v1 conmon: package: /usr/bin/conmon is owned by conmon 1:2.1.4-1 path: /usr/bin/conmon version: 'conmon version 2.1.4, commit: bd1459a3ffbb13eb552cc9af213e1f56f31ba2ee' cpuUtilization: idlePercent: 94.95 systemPercent: 1.54 userPercent: 3.51 cpus: 4 distribution: distribution: arch version: unknown eventLogger: file hostname: Alex idMappings: gidmap: - container_id: 0 host_id: 1000 size: 1 - container_id: 1 host_id: 100000 size: 65536 uidmap: - container_id: 0 host_id: 1000 size: 1 - container_id: 1 host_id: 100000 size: 65536 kernel: 5.15.68.1-microsoft-standard-WSL2 linkmode: dynamic logDriver: k8s-file memFree: 4470984704 memTotal: 8332820480 networkBackend: netavark ociRuntime: name: crun package: /usr/bin/crun is owned by crun 1.6-1 path: /usr/bin/crun version: |- crun version 1.6 commit: 18cf2efbb8feb2b2f20e316520e0fd0b6c41ef4d spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL os: linux remoteSocket: path: /mnt/wslg/runtime-dir/podman/podman.sock security: apparmorEnabled: false capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT rootless: true seccompEnabled: true seccompProfilePath: /etc/containers/seccomp.json selinuxEnabled: false serviceIsRemote: false slirp4netns: executable: /usr/sbin/slirp4netns package: /usr/bin/slirp4netns is owned by slirp4netns 1.2.0-1 version: |- slirp4netns version 1.2.0 commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383 libslirp: 4.7.0 SLIRP_CONFIG_VERSION_MAX: 4 libseccomp: 2.5.4 swapFree: 2147483648 swapTotal: 2147483648 uptime: 2h 26m 43.00s (Approximately 0.08 days) plugins: authorization: null log: - k8s-file - none - passthrough - journald network: - bridge - macvlan volume: - local registries: search: - docker.io - quay.io store: configFile: /home/alex/.config/containers/storage.conf containerStore: number: 4 paused: 0 running: 0 stopped: 4 graphDriverName: overlay graphOptions: {} graphRoot: /home/alex/.local/share/containers/storage graphRootAllocated: 269427478528 graphRootUsed: 17116053504 graphStatus: Backing Filesystem: extfs Native Overlay Diff: "false" Supports d_type: "true" Using metacopy: "false" imageCopyTmpDir: /var/tmp imageStore: number: 71 runRoot: /mnt/wslg/runtime-dir/containers volumePath: /home/alex/.local/share/containers/storage/volumes version: APIVersion: 4.2.1 Built: 1662619974 BuiltTime: Thu Sep 8 03:52:54 2022 GitCommit: 62b324ddf718411b1d4d0ba8117c632f7f984a38-dirty GoVersion: go1.19 Os: linux OsArch: linux/amd64 Version: 4.2.1 ```
podman-compose --version ```bash $ podman-compose --version podman-compose version: 1.0.4 ['podman', '--version', ''] using podman version: 4.2.1 podman-compose version 1.0.4 podman --version podman version 4.2.1 exit code: 0 ```
aleksanderostrup commented 1 year ago

I think that it might be related to permission rights, but I'm not sure.

Are all the Dockerfile commands being executed as root? Or maybe this has changed, which is the cause of the problem.

alexnfsc175 commented 1 year ago

@aleksanderostrup I'm running my containers without root privileges, with Rootless Podman, I can't tell from the error messages if it's a permissions problem, the error I can see in the console is this: Error: Missing node-pty Is there any way to debug this kind of problem?

aleksanderostrup commented 1 year ago

Not that I know of. Hopefully one of the devs will take a look at this in due time.

chrmarti commented 1 year ago

The base images now pass down the "remoteUser" config (among other properties). Try setting it explicitly to root if you don't set it in your devcontainer.json to some other user by adding "remoteUser": "root". Does that help?

github-actions[bot] commented 1 year ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!