Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
How to send STDIN to docker process

I have a nodemon running in a docker container in development. I have successfully setup live reloading when code changes.

However sometimes I write some code where nodemon crashes. Nodemon can be manually restarted when you type 'rs' (when running locally).

The problem is that within a docker container I can't get it to restart.

I've tried the following with no luck:

docker exec -it add92j rs ====> rs not found

docker exec -it add92j sh -c echo rs ====> just echos rs

I've also tried docker attach and then typing rs but it doesn't work.

I've also tried using the shell with docker exec -it sh, getting the process with ps aux and then:

echo rs > /proc/PID/fd/0

But that also doesn't work. (Note I've tried all the above variants with rs and rs\n and using printf and echo).

In the nodemon github I see that it looks for 'rs\n' to trigger a restart and there is a reference to SIGUSR2. Hence I've tried also kill -12 PID but that just kills my process. Note that I checked to see that 12 is indeed SIGUSR2 in my container.

The processes actually running in my container with ps aux are:

 1 root       0:00 npm
14 root       0:00 sh -c DEBUG=app:* nodemon
15 root       0:00 node /workspace/node_modules/.bin/nodemon
29 root       0:00 sh -c node server/register.js
30 root       0:01 node server/register.js

So my question is, how do I send text to stdin for a process in docker?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Running the nodemon container with a -t tty and -i for stdin allows you to control nodemon after a docker attach

→ CID=$(docker run -dti dply/node-docker-demo-app:nodemon)
→ docker attach $CID
rs
[nodemon] starting `node /app/index.js`
Listening on 8080
^Csigint
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!