【问题标题】:Jupyter docker: Volume: Permission deniedJupyter docker:卷:权限被拒绝
【发布时间】:2026-01-16 19:05:03
【问题描述】:

你使用的是什么 docker 镜像?

jupyter/minimal-notebook

你运行什么完整的 docker 命令来启动容器(省略敏感值)?

# Creating a volume with docker create -- volume
docker volume create --name stagingarea
# Start a jupyter minimal notebook container and map the volume (stagingarea) to a container directory (/data/stagingarea)
docker run -d \
  -v stagingarea:/home/jovyan/stagingarea\
  -p 8888:8888 \
  jupyter/minimal-notebook

在容器运行后您会采取哪些步骤来重现问题?

  1. 访问 http://localhost:8888 并使用令牌登录
  2. 转到 /home/jovyan/stagingarea
  3. 尝试在卷中创建一个简单的笔记本或文本文件 (Greetings.txt)

您预计会发生什么?

  • 我想要:创建一个简单的文本文件并将其保存在卷中
  • 为了:与其他容器共享此文本文件

实际发生了什么?

我为什么要这样做

  • 我想创建一个暂存区,以便 jupyter 中的 python 程序可以从一个源下载数据,将其写入 docker 卷,而另一个服务(如 postgres,..)可以从该卷读取数据并摄取它。

我尝试了什么:

以 root 身份连接

  • 当我运行 jupyter docker 映像时它可以工作。作为 root -e GRANT_SUDO=yes \
# Creating a volume with docker create -- volume
docker volume create --name stagingarea
# Start a jupyter minimal notebook container and map the volume (stagingarea) to a container directory (/data/stagingarea)
docker run -d \
  -v stagingarea:/home/jovyan/stagingarea\
  -p 8888:8888 \
  -e JUPYTER_TOKEN=letmein \
  -e GRANT_SUDO=yes \
  --user root \
  jupyter/minimal-notebook

使用绑定挂载

docker run -d \
  -v -v /Users/paulogier/87-docker_parent/usingjupyterwithdocker/Step7_Volumes/stagingarea:/home/jovyan/stagingarea )
  -p 8888:8888 \
  -e JUPYTER_TOKEN=letmein \
  jupyter/minimal-notebook

【问题讨论】:

标签: docker jupyter-notebook


【解决方案1】:

关闭:https://github.com/jupyter/docker-stacks/issues/1187 它需要使用 --user root 运行容器,与我提出的解决方案相同。

【讨论】:

    最近更新 更多