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

155
Visualizações
Docker container exits right away, but not when using the Docker desktop application to run the command

I am creating a console-based app in Node JS. No ports are being used... It's just a basic app. The problem I am having is using Docker to run my app.

Here's my docker file:

FROM node:16

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

CMD [ "node", "index.js" ]

After building the image, I try to run 'docker run ' and the container just exits right away. However, when i use the Docker desktop app, after building the image, if I click 'run' it builds the container and does not exit, but actually runs. When I log into that container, I am able to run 'node index.js' and my node app runs fine.

My question is, why does it work when using the GUI docker run and not my command? Also, why do I have to run 'node index.js' manually when the docker file should take care of that?

Commands to build image and run the container:

Image build:

docker build -t 'appname' .

Create container:

docker run 'appname'
about 4 years ago · Juan Pablo Isaza
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