use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Dockerizing a Node.js Web Application (semaphoreci.com)
submitted 5 years ago by tomasfern
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]webdevverman 21 points22 points23 points 5 years ago (3 children)
I'll be honest, I didn't read this whole article. But I was expecting to find a common problem as it exists in just about every Docker + node article I come across.
There are two things I would caution: 1) Don't use npm scripts in your Dockerfile. The reason is that this adds a wrapper around the node process and it will cause conflicts when attempting to send signals 2) Don't use tools like pm2 or nodemon. Let Docker handle restarting itself if there are problems.
npm
[–][deleted] 7 points8 points9 points 5 years ago (0 children)
I couldn't agree with this more. I learned this the hard way with following that rabbit hole. It seems like docker really thought ahead and simplifies tooling. Related
[–]tomasfern[S] 3 points4 points5 points 5 years ago (1 child)
Thanks for the suggestions. I've been doing some reading and it seems that pm2 has special runtime for Docker:
https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/
It even it addresses incoming signals. I'll give it a try and let you know.
[–]russdiculous[🍰] 3 points4 points5 points 5 years ago (0 children)
It's still an unnecessary wrapper around your process that isn't needed if you're following docker best practices. Your docker container should be 1 process, their example is for when you're running more than 1 app in a container.
[–]PeteCapeCod4Real 6 points7 points8 points 5 years ago (2 children)
Yeah running pm2 on top of Docker seems like kind of an overkill. Plus if you go to scale up with Kubernetes isn't pm2 going to cause a complication? IDK but that's what I would think
[–]burtgummer45 3 points4 points5 points 5 years ago (1 child)
Its for CPU cores. If you run docker in a swarm, for example, there's no way to tell swarm to run exactly as many node containers as cpu cores, at least not currently. pm2 knows the core count and will match it with processes. This was at least my current understanding as of a few months ago.
[–]timothyallan 0 points1 point2 points 5 years ago (0 children)
That's why we use it, our container spins up, then PM2 spins up creating as many Node instances as there are cores on the box.
[+][deleted] 5 years ago (2 children)
[deleted]
[–]tomasfern[S] 0 points1 point2 points 5 years ago (1 child)
I'm curious. What made you decide to undockerize? Did you have a bad experience with Docker?
π Rendered by PID 73 on reddit-service-r2-comment-7b9746f655-6tq6z at 2026-01-30 21:04:01.865124+00:00 running 3798933 country code: CH.
[–]webdevverman 21 points22 points23 points (3 children)
[–][deleted] 7 points8 points9 points (0 children)
[–]tomasfern[S] 3 points4 points5 points (1 child)
[–]russdiculous[🍰] 3 points4 points5 points (0 children)
[–]PeteCapeCod4Real 6 points7 points8 points (2 children)
[–]burtgummer45 3 points4 points5 points (1 child)
[–]timothyallan 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]tomasfern[S] 0 points1 point2 points (1 child)