运行 Docker 背景中的 Jupyter Notebook

Run Jupyter Notebook in the Background on Docker

我正在尝试 运行 在后台运行一个 jupyter notebook,而不向控制台打印任何内容。我在 question for bash:

中找到了这个解决方案

jupyter notebook &> /dev/null &

但我 运行 在 docker 容器中安装 jupyter,并希望它通过 CMD 在后台启动。我怎样才能在 sh 中做同样的事情?

我使用以下设置让它工作:
https://github.com/jupyter/docker-stacks/tree/master/minimal-notebook

诀窍是安装 tini 并将以下代码放入 start-notebook.sh 脚本中:

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

然后将其添加到路径中:
COPY start-notebook.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/start-notebook.sh

然后我可以设置 CMD ["start-notebook.sh"] 在启动时在后台启动带有 jupyter 运行 的容器。

你可以这样做,执行下面的命令

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

如果您在 docker 容器中以 root 身份执行 jupyter notebook 命令,您可能会看到 jupyter 命令需要 --allow-root 选项的警告.