Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

327
Vistas
Why does the following docker-compose execution exit without waiting for user input?

When I run the following simple Node.js code (index.js) using Docker, the code executes as expected - waiting for user input. But when I run the same code using Docker-Compose, Node.js exits before waiting for user input.

I've been able to run the Node application using the Dockerfile, but not Docker-Compose

Here is the index.js file that I'm able to run in the Dockerfile (but not Docker-Compose):

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

readline.question(`What's your name? `, (name) => {
  console.log(`Hi ${name}!`)
  readline.close()
});

And the Dockerfile I used:

FROM node:12.2

ENV NODE_ENV=development
ENV NPM_CONFIG_LOGLEVEL warn

WORKDIR /app
COPY package*.json /app/
RUN npm install && npm cache clean --force

WORKDIR /app/src
CMD ["node", "index.js"]


As with the Dockerfile experience:

```shell
$ docker build -t commandline .
...
$ docker run -it --rm -v $(pwd)/src:/app/src commandline
What's your name? Scott
Hi Scott!

I expected the Docker-Compose version to execute the same way, but it exits the Node and Docker process before the user has an opportunity to respond:

$ docker-compose up
Creating mega_node_1 ... done
Attaching to mega_node_1
node_1  | What's your name? mega_node_1 exited with code 0
$ 
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda