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

Stop docker container after closing kernel #10

Closed
vmenger opened this issue Jan 7, 2021 · 5 comments
Closed

Stop docker container after closing kernel #10

vmenger opened this issue Jan 7, 2021 · 5 comments
Labels
🐛 bug Something isn't working
Milestone

Comments

@vmenger
Copy link
Contributor

vmenger commented Jan 7, 2021

Currently, docker containers keep running when a kernel/notebook is closed. This can start eating up a lot of resources over time.

To investigate:

  • How does jupyter arrange cleanup of kernels?
  • Can this command be integrated to stop docker container?
@gogasca
Copy link

gogasca commented Jan 15, 2021

I have the same issue.
When a kernel stopped, I would be interested in capturing that signal and call the docker stop command. I would assume we would need to collect the docker image id to be able to call correctly docker stop. I'm not a iPython kernel expert but seems to be this needs to be handled directly by a Kernel Manager such as here: https://github.com/jupyter/notebook/blob/master/notebook/services/kernels/kernelmanager.py

This is my kernel.json file.

{
 "argv": [
  "/usr/bin/docker",
  "run",
  "--network=host",
  "-v",
  "{connection_file}:/connection-spec",
  "gcr.io/deeplearning-platform-release/tf2-cpu.2-4:latest",
  "python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "/connection-spec"
 ],
 "display_name": "tensorflow",
 "language": "python"
}

Update: Not able to reproduce it anymore. Will investigate further

@vmenger
Copy link
Contributor Author

vmenger commented Jan 16, 2021

The normal behaviour for a container when running in the background is to stop whenver the CMD/ENTRYPOINT command stops. In this case the ipykernel receives the shutdown command, after which it terminates and the docker should automatically terminate.

For this project it works correctly most of the time, but in some cases the docker keeps running. I have yet to find a complete reproducible case, but will update if I find one.

@MrMino
Copy link
Owner

MrMino commented Jan 17, 2021

@vmenger @gogasca IIRC, back at the time I was developing the first release I had the same problem. Changing the default interrupt mode fixed the issue. I don't think this change was released, but it's merged to master (5ca4d06).

BTW. I've just realized that the release I've put out on PyPI either disappeared or was never deployed properly in the first place. Fixing this as we speak. 1.0.1 with the change mentioned above is coming too.

@MrMino MrMino added the 🐛 bug Something isn't working label Jan 17, 2021
@MrMino
Copy link
Owner

MrMino commented Jan 17, 2021

There you go. dockernel==1.0.1 should fix this issue.

I have no idea why I left all of this without releasing it properly, sorry for that.

@MrMino
Copy link
Owner

MrMino commented Mar 21, 2021

Closing this one. If anyone has this same problem again - please make sure it's dockernel==1.0.2 and if so, create a new issue. Thanks!

@MrMino MrMino closed this as completed Mar 21, 2021
@MrMino MrMino added this to the 1.0.2 milestone Apr 4, 2021
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

3 participants