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

Can't rely on the Docker restart policy #11

Closed
31z4 opened this issue Jun 23, 2016 · 9 comments · Fixed by #207
Closed

Can't rely on the Docker restart policy #11

31z4 opened this issue Jun 23, 2016 · 9 comments · Fixed by #207
Assignees

Comments

@31z4
Copy link

31z4 commented Jun 23, 2016

Whether you use STOP or KILL there is no way Docker will restart killed containers automatically. It would be great to have an ability to kill a process inside a running container so that the container will be restarted in case of using a corresponding restart policy.

More general approach can be implemented with the new "kill" command EXEC:CMD. To address the issue described above I would use EXEC:kill 1.

@alexei-led
Copy link
Owner

Thank you,
This is a good idea. I will add an option to kill a process running inside the container. There is one problem, I need to solve: how to find process id. The main process can be started from a shell script, and if used did not start it properly (with exec command) it will have process id not equal to 1. Maybe to support kill command by name too?

@31z4
Copy link
Author

31z4 commented Jun 27, 2016

Yes, kill by name would be useful in that case.

@alexei-led
Copy link
Owner

On other hand, Pumba is already able to kill container (read "main process" within it), sending any Linux termination signal, exactly like kill command does. To force kill use KILL command with any signal (the default signal is SIGKILL). So, it already works now. I'm closing this issue.

@31z4
Copy link
Author

31z4 commented Jun 28, 2016

Please, read carefully. I wrote that after using KILL containers are not restarted automatically by the Docker if restart policy is set. Maybe this issue is only related to Docker Beta for Mac which I use?

@alexei-led
Copy link
Owner

It seems that Docker will restart container only when/if then main process exited by itself and its restart depends on defined restart policy. I've tried to kill PID 1 inside the container (using kill command), without success. I can kill any other PID inside the container, but not the PID 1.

So, I think that running kill 1 inside the container will not help. Or at least, I have no idea how to do it.

On the other hand, if you will not use Docker restart policy and will use some scheduler (like swarm, kubernets or fleet), the scheduler will usually restart your container.

What is the use case, you are trying to achieve, by killing PID 1? Maybe there is an alternative approach.

@alexei-led
Copy link
Owner

It seems that killing process with ID=1 is not allowed in Linux (from kill man)

@31z4
Copy link
Author

31z4 commented Jun 29, 2016

docker exec -it container kill 1 works just fine for me at least with 31z4/storm image. So I think it depends on the linux distro.

I don't use the scheduler and don't plan to do this.

My goal is to automate failure testing for a data processing pipeline which is built on top of the Apache Storm. I have several Storm's Supervisors running in separate containers. Each of these containers have restart policy set to always. During the test I'm pushing documents to the pipeline while making chaos by executing kill 1 in the random container. Containers are being restarted by the Docker and I expect that after chaos is stopped, all the documents eventually will be processed by the pipeline.

@alexei-led alexei-led reopened this Jun 29, 2016
@alexei-led alexei-led self-assigned this Jun 29, 2016
@alexei-led
Copy link
Owner

I think it will be enough to add EXEC command, as you've proposed. This will allow to call any command in running container. Will do it. Thank you.

@aodhan-domhnaill
Copy link
Contributor

Did this feature get added? I don't see any reference in the documentation

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

Successfully merging a pull request may close this issue.

3 participants