pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

PM2 logs errors when running in distroless

Open Sineaggi opened this issue 5 years ago • 4 comments

What's going wrong?

When running an app in docker on a distroless base image, we see these two errors being logged.

The Dockerfile

FROM node:12 AS build-env

ENV HOME=/usr/src/app
ENV NPM_CONFIG_PREFIX=$HOME/.npm-global
WORKDIR /usr/src/app

COPY . .

RUN npm ci --only=production
RUN npm i -g pm2

FROM gcr.io/distroless/nodejs:12-debug

COPY --from=build-env /usr/src/app /app
WORKDIR /app

EXPOSE 3000

ENV PATH=$PATH:/nodejs/bin

CMD [ ".npm-global/bin/pm2-runtime", "--format", "pm2.json" ]

error logged while running, doesn't affect the process

2020-11-04T16:30:58: PM2 error: Error while getting CLK_TCK Error: spawn /bin/sh ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn /bin/sh',
  path: '/bin/sh',
  spawnargs: [ '-c', 'getconf CLK_TCK' ],
  cmd: 'getconf CLK_TCK'
}
2020-11-04T16:30:58: PM2 error: Error while getting PAGESIZE Error: spawn /bin/sh ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn /bin/sh',
  path: '/bin/sh',
  spawnargs: [ '-c', 'getconf PAGESIZE' ],
  cmd: 'getconf PAGESIZE'
}

How could we reproduce this issue?

Run a simple application under pm2 on a distroless container.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Wed Nov 04 2020 16:54:07 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.0
node version         : 12.18.3
node path            : not found
argv                 : /nodejs/bin/node,/usr/src/example/.npm-global/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.0
node version         : 12.18.3
node path            : not found
argv                 : /nodejs/bin/node,/usr/src/example/.npm-global/bin/pm2,report
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
cpus nb              : 3
freemem              : 1030197248
totalmem             : 2084245504
home                 : /usr/src/example
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
└─────┴───────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/usr/src/example/.pm2/pm2.log last 20 lines:
PM2        | 2020-11-04T16:54:07: PM2 log: ===============================================================================
PM2        | 2020-11-04T16:54:07: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2020-11-04T16:54:07: PM2 log: Time                 : Wed Nov 04 2020 16:54:07 GMT+0000 (Coordinated Universal Time)
PM2        | 2020-11-04T16:54:07: PM2 log: PM2 version          : 4.5.0
PM2        | 2020-11-04T16:54:07: PM2 log: Node.js version      : 12.18.3
PM2        | 2020-11-04T16:54:07: PM2 log: Current arch         : x64
PM2        | 2020-11-04T16:54:07: PM2 log: PM2 home             : /usr/src/example/.pm2
PM2        | 2020-11-04T16:54:07: PM2 log: PM2 PID file         : /usr/src/example/.pm2/pm2.pid
PM2        | 2020-11-04T16:54:07: PM2 log: RPC socket file      : /usr/src/example/.pm2/rpc.sock
PM2        | 2020-11-04T16:54:07: PM2 log: BUS socket file      : /usr/src/example/.pm2/pub.sock
PM2        | 2020-11-04T16:54:07: PM2 log: Application log path : /usr/src/example/.pm2/logs
PM2        | 2020-11-04T16:54:07: PM2 log: Worker Interval      : 30000
PM2        | 2020-11-04T16:54:07: PM2 log: Process dump file    : /usr/src/example/.pm2/dump.pm2
PM2        | 2020-11-04T16:54:07: PM2 log: Concurrent actions   : 2
PM2        | 2020-11-04T16:54:07: PM2 log: SIGTERM timeout      : 1600
PM2        | 2020-11-04T16:54:07: PM2 log: ===============================================================================

Sineaggi avatar Nov 04 '20 17:11 Sineaggi

Need help on this as well.

algo7 avatar Mar 16 '21 21:03 algo7

Same problem here ... probably because there is no shell in distroless

geoynomous avatar Feb 17 '23 18:02 geoynomous

Still no update?

algo7 avatar Feb 26 '23 16:02 algo7

Same problem here, no updates?

mcarrf90-bz avatar May 13 '25 18:05 mcarrf90-bz