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

Always more than 10 sec to "down" the container #156

Open
Gabb1995 opened this issue Mar 13, 2023 · 2 comments
Open

Always more than 10 sec to "down" the container #156

Gabb1995 opened this issue Mar 13, 2023 · 2 comments

Comments

@Gabb1995
Copy link

image

As can be seen by the image above when running docker-compsoe down, it always takes a bit more than 10 seconds to "down" the container. Other containers are much faster.

Just want to maybe start a discussion on why this is happening? Is it on purpose, is it a bug?

@Grokzen
Copy link
Owner

Grokzen commented Mar 13, 2023

So by default docker is under this rule

Docker has limited patience when it comes to stopping containers.
There’s a timeout, which is 10 seconds by default for each container.
If even one of your containers does not respond to SIGTERM signals, Docker will wait for 10 seconds at least.

There is a flag at least for docker where timeouts can be lowered, if you need a shorter time to stop them you should look into that one and if docker-compose supports that flag in the config.

But the core issue is bash and that this container runs a bash script that runs all redis servers.

Normally, bash will ignore any signals while a child process is executing.
Starting the server with & will background it into the shell's job control system,
with $! holding the server's PID (to be used with wait and kill).
Calling wait will then wait for the job with the specified PID (the server) to finish, or for any signals to be fired.

I guess adding in a SIGTERM trap should not be that difficult to exit out the container more correct

@johan-seesaw
Copy link

I just corrected this in my own usage using dumb-init and execing the tail. Seemed to work well.

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

No branches or pull requests

3 participants