How to run a shell command in container when it was created?

48 views
Skip to first unread message

qxu...@gmail.com

unread,
Aug 22, 2017, 11:35:16 PM8/22/17
to Project Jupyter
My jupyterhub runs under single-user mode. Every user has a container running jupyter notebook. I need to exec a shell command when the container starts up. 

There might be so configuration in jupyterhub_config.py.
like:
#jupyterhub_config.py
c = get_config()
...
c.DockerSpawner
在此输入代码...

But I don't know exactly what the keys are. 

Thanks in advance!


MinRK

unread,
Aug 26, 2017, 8:38:27 PM8/26/17
to Project Jupyter

You can modify the command in your Dockerfile, e.g.

FROM jupyter/scipy-notebook:c8797824e8c0
ADD preflight.sh
CMD ['preflight.sh']

where preflight.sh is something like:

#!/usr/bin/env bash
echo 'hello! I'm about to start'

# your setup code here

# your script should end with this:
exec jupyterhub-singleuser $@

-Min


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/7c2fc6bd-7b60-46dd-9f1d-25d7beb8e99a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

qxu...@gmail.com

unread,
Aug 28, 2017, 9:12:34 PM8/28/17
to Project Jupyter

thank you!
Reply all
Reply to author
Forward
0 new messages