Hi all,
I’m exploring a design for my project Dockyter, an IPython/Jupyter extension that adds a %%docker magic to run shell commands inside Docker containers while keeping the base Python environment light.
The intended user-facing flow looks roughly like this:
%%docker -v /home/jovyan/data:/input image:latest
!tool --input /input/file.txt
Internally this would translate !tool ... into something like:
docker run --rm -v /home/jovyan/data:/input image:latest \
bash -lc "tool --input /input/file.txt"
after %%docker has configured the image and args.
Architecture questions
I’m unsure where Dockyter should live in the Jupyter stack (kernel process + protocol, as described in kernel architecture docs).
-
IPython extension only:
%load_ext dockyter, patchInteractiveShell.systemso that!goes through Docker when enabled. -
Integrated into ipykernel: same behaviour, but configurable via traitlets and enabled/disabled per kernel.
-
Separate “Docker-aware” kernel: a dedicated kernel that always loads and configures this behaviour.
From the point of view of people running JupyterHub/Binder which approach fits real-world deployments best?
Security questions
I realise notebooks already allow arbitrary Python, but a magic that makes it easy to launch containers raises extra concerns. I’m currently thinking:
-
basic safeguards in the kernel (filtering dangerous Docker flags, allow/deny lists for images.
-
real isolation from the surrounding infrastructure (containers/pods per user, resource limits, network/volume policies).
Questions:
-
Does this threat model sound reasonable, or it present too many problems ?
-
Would you expect such a feature to be “off” by default and only enabled explicitly (config or kernelspec), or is a plain
%load_ext dockyterextension acceptable? -
Are there examples of similar projects that have worked well (or badly) in JupyterHub/Binder environments?
Thank you in advance for your help !