Search code examples
dockervisual-studio-codeairflowvscode-debuggervscode-remote

VS code terminal process failed to launch as debugging in attached running container


I'm trying to setup Airflow debugging environment with VS code using Remote - containers plugin. What I did so far:

  1. docker-compose up the image apache/airflow:2.2.4 with Docker Desktop community 2.4 on macOS 10.13.6
  2. Attach to the running airflow-scheduler container with Remote - containers plugin
  3. Compose a launch.json file with
"version": "0.2.0",
"configurations": [
  {
    "name": "Airflow Test",
    "type": "python",
    "request": "launch",
    // $ which airflow
    "program": "/home/airflow/.local/bin/airflow",
    "console": "integratedTerminal",
    "args": [
      "dags",
      "test",
      "task_of_middleware",
      "2022-04-08"
    ],
    "justMyCode": true
  }
]

VS code pops up error below when I start debugging:

The terminal process failed to launch: Path to shell executable "/sbin/nologin" does not exist.

The attached running container shows error:

[1382 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd ; readlink /proc/$pid/ns/mnt ; cat /proc/$pid/stat | tr "
[1518 ms] Container server: Error: spawn /sbin/nologin ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1525 ms] Error: spawn /sbin/nologin ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[1530 ms] Container server: (node:11888) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)

I think the container runs normally since I'm able to connect to container shell via Docker Desktop and run Airflow test command. Any advice would be appreciated.


Solution

  • Not sure if this is the best practice, I found a way to ease the error and make debugger run normally. Put a config into the Attached container configuration files by select Remote-Containers: Open Container Configuration File from the Command Palette after attaching.

    // Container user VS Code should use when connecting
    "remoteUser": "root"
    

    Reference here.