Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda