Run Jupyter Notebook in the Background on Docker

末鹿安然 提交于 2019-12-22 04:52:55

问题


I am trying to run a jupyter notebook in the background without printing anything to the console. I found this solution in a question for bash:

jupyter notebook &> /dev/null &

But I am running jupyter in a docker container and want it to start in the background via CMD. How can I do the same in sh?


回答1:


I got it to work using the setup from:
https://github.com/jupyter/docker-stacks/tree/master/minimal-notebook

the trick was to install tini and put the following code into a start-notebook.sh script:

#!/bin/bash
exec jupyter notebook &> /dev/null &

this is than added to the path with:
COPY start-notebook.sh /usr/local/bin/ and
RUN chmod +x /usr/local/bin/start-notebook.sh

Then I could set CMD ["start-notebook.sh"] to start up the container with jupyter running in the background on start.




回答2:


You can do that, executing the below command

jupyter notebook --allow-root &> /dev/null &

You might see the warning that jupyter command needs --allow-root option if you execute jupyter notebook command as a root in a docker container.



来源:https://stackoverflow.com/questions/34865097/run-jupyter-notebook-in-the-background-on-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!