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?
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