LoginSignup
1
0

More than 1 year has passed since last update.

Docker環境で出るホットリロード開発エラーを解決する

Posted at

原因

Dockerfileで FROM node:18.6.0-slim のように slimイメージを使用している場合、
ファイル変更を検知してホットリロードがかかるタイミングで、エラーで落ちる。

/bin/sh: 1: ps: not found
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn ps ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ps',
  path: 'ps',
  spawnargs: [ '-o', 'pid', '--no-headers', '--ppid', 40 ]
}

恐らくホットリロード時に内部でpsコマンドを叩いてプロセスを確認している。

対策

psコマンドがなくて落ちているだけなので、psコマンドを入れてあげれば解決する。

# Dockerfileに以下を追加
RUN apt-get update -qq \
  && apt-get install -qy  \
  procps \
  --no-install-recommends
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0