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

Docker image ignores signals #65088

Open
1 task done
cristi8 opened this issue Apr 26, 2024 · 1 comment
Open
1 task done

Docker image ignores signals #65088

cristi8 opened this issue Apr 26, 2024 · 1 comment
Labels
examples Issue/PR related to examples

Comments

@cristi8
Copy link

cristi8 commented Apr 26, 2024

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

n/a

Which example does this report relate to?

with-docker

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

The docker container ignores all signals.

I also found the problem. Things got broken by #59756 where the main process in the docker container was replaced with a bash shell, handling the env variable. If i use the original

ENV HOSTNAME "0.0.0.0"

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

things work as expected.

My guess is the fix is not that easy, as it might reopen #58657

IMHO, the HOSTNAME env variable name choice was not that good for specifying the network interface where it binds. And it might be a good time to change it to something more suitable now, since from what i understood, it was recently introduced and not documented anyway

Expected Behavior

Current behavior: it ignores Ctrl+C
Expected: It finishes the current connections and gracefully closes

To Reproduce

Use the example Dockerfile, create a container, run it with -it, then press Ctrl+C

@cristi8 cristi8 added the examples Issue/PR related to examples label Apr 26, 2024
@cristi8
Copy link
Author

cristi8 commented Apr 29, 2024

Found a workaround that still works for k8s / ECS:

# HOSTNAME variable is set like this to ensure it's not overwritten by k8s / ECS when running the container
CMD ["/bin/sh", "-c", "exec env HOSTNAME=0.0.0.0 node server.js"]

by using exec, the node process becomes PID 1 and handles signals correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Issue/PR related to examples
Projects
None yet
Development

No branches or pull requests

1 participant