Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl-C does not stop log4brains preview when run in Docker #58

Open
francoisvdv opened this issue Dec 10, 2021 · 2 comments
Open

Ctrl-C does not stop log4brains preview when run in Docker #58

francoisvdv opened this issue Dec 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@francoisvdv
Copy link

Bug Report

Great project, thanks for your work! I am trying to run log4brains in Docker and I encounter the following. If I have time I will try to submit a PR fixing this, but for now I will submit the issue.

Description

Ctrl-C does not stop log4brains preview when run in Docker

Steps to Reproduce

  1. Run 'log4brains preview' in Docker with the following command:
docker run --rm -ti -v $(pwd):/workdir -p 4004:4004 thomvaill/log4brains preview 
  1. Press ctrl-c
  2. The container does not stop

Expected Behavior

In step 3, log4brains and the container should stop.

Context

You can stop the container by running docker ps and running docker stop <container id> but this is cumbersome.

Environment

  • Log4brains version: the version in Docker image (1.0.0-beta.11)
    thomvaill/log4brains latest 7bb84c921b02 6 weeks ago 412MB
  • Node.js version: version in Docker image
  • OS and its version: version in Docker image
  • Browser information: Firefox

Possible Solution

I do not have a solution right now, but maybe playing with the Docker entrypoint / cmd can fix this.

@francoisvdv francoisvdv added the bug Something isn't working label Dec 10, 2021
@ms-ati
Copy link

ms-ati commented May 1, 2023

@francoisvdv according to https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals

Node.js was not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to SIGINT (CTRL-C) and similar signals. As of Docker 1.13, you can use the --init flag to wrap your Node.js process with a lightweight init system that properly handles running as PID 1.

docker run -it --init node

You can also include Tini directly in your Dockerfile, ensuring your process is always started with an init wrapper.

Is this the right way to solve this?

@ms-ati
Copy link

ms-ati commented May 1, 2023

I can confirm that adding --init to my docker run command does fix the CTRL-C issue for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants