Dockerized Node JS project getting: "command failed signal SIGTERM" error Dockerized Node JS project getting: "command failed signal SIGTERM" error kubernetes kubernetes

Dockerized Node JS project getting: "command failed signal SIGTERM" error


I assume you're either incorrectly specifying your script in the package.json or your script is not server.js.

A minimal repro of your question works:

Using the Node.JS Getting Started guide's example with one minor tweak:https://nodejs.org/en/docs/guides/getting-started-guide/

NOTE Change const hostname = '127.0.0.1'; to const hostname = '0.0.0.0'; This is necessary to access the containerized app from the host.

Adding a package.json because you have one and to show npm start:

package.json:

{    "name": "66281738",    "version": "0.0.1",    "scripts": {        "start": "node app.js"    }}

NOTE I believe npm start defaults to "start": "node server.js"

Using your Dockerfile and:

QUESTION="66281738"docker build --tag=${QUESTION} --file=./Dockerfile .docker run --interactive --tty --publish=7777:3000 ${QUESTION}

Yields:

> 66281738@0.0.1 start> node app.jsServer running at http://0.0.0.0:3000/

NOTE docker run binds the container's :3000 port to the host's :7777 just to show these need not be the same.

Then:

curl --request GET http://localhost:3000/

Yields:

Hello World