gpt4 book ai didi

docker - 如何使用 docker 镜像为 Jupyter notebook 挂载本地文件夹?

转载 作者:行者123 更新时间:2023-12-02 19:04:03 25 4
gpt4 key购买 nike

我在下面使用 docker 图像:
https://hub.docker.com/r/gw000/keras-full

效果很好;但是,我想挂载一个本地文件夹,以便保存和使用本地笔记本文件。我使用以下命令:

docker run -d -p 8888:8888 -v c:/Jupyter:/srv gw000/keras-full

命令运行成功;但是,我无法创建新笔记本,因为我收到以下错误消息:

Permission denied: Untitled.ipynb



我尝试了以下方法:
  • 我已授予 Jupter 文件夹“完全”访问权限(“每个人”用户)
  • 我已经从第一个提交的答案中尝试了命令
  • 我尝试过使用普通模式和管理员模式的 Firefox 和 Edge 浏览器

  • Docker 镜像需要密码“keras”,如下例所示:
    docker run -d -p 8888:8888 -v $(pwd):/srv gw000/keras-full

    我无法弄清楚如何同时使用映射文件夹和密码。

    我的环境:
  • Windows 10 专业版
  • Docker 桌面

  • docker 日志:
    [I 10:35:10.240 NotebookApp] Writing notebook server cookie secret to /home/user/.local/share/jupyter/runtime/notebook_cookie_secret
    [W 10:35:10.844 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
    [I 10:35:13.007 NotebookApp] jupyter_tensorboard extension loaded.
    [I 10:35:13.009 NotebookApp] Serving notebooks from local directory: /srv
    [I 10:35:13.009 NotebookApp] 0 active kernels
    [I 10:35:13.009 NotebookApp] The Jupyter Notebook is running at:
    [I 10:35:13.009 NotebookApp] http://[all ip addresses on your system]:8888/?token=...
    [I 10:35:13.009 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [I 10:35:18.003 NotebookApp] 302 GET / (172.17.0.1) 0.50ms
    [I 10:35:18.015 NotebookApp] 302 GET /tree? (172.17.0.1) 0.97ms
    [I 10:35:21.563 NotebookApp] 302 POST /login?next=%2Ftree%3F (172.17.0.1) 1.40ms
    [I 10:35:26.118 NotebookApp] Creating new notebook in
    [I 10:35:26.151 NotebookApp] Writing notebook-signing key to /home/user/.local/share/jupyter/notebook_secret
    [W 10:35:26.166 NotebookApp] 403 POST /api/contents (172.17.0.1): Permission denied: Untitled.ipynb
    [W 10:35:26.166 NotebookApp] Permission denied: Untitled.ipynb
    [W 10:35:26.167 NotebookApp] 403 POST /api/contents (172.17.0.1) 49.41ms referer=http://localhost:8880/tree?
    [I 10:36:38.981 NotebookApp] 302 GET /tree (172.17.0.1) 1.66ms
    [I 10:36:42.373 NotebookApp] 302 POST /login?next=%2Ftree (172.17.0.1) 1.12ms
    [I 10:36:45.459 NotebookApp] Creating new notebook in
    [W 10:36:45.475 NotebookApp] 403 POST /api/contents (172.17.0.1): Permission denied: Untitled.ipynb
    [W 10:36:45.476 NotebookApp] Permission denied: Untitled.ipynb
    [W 10:36:45.476 NotebookApp] 403 POST /api/contents (172.17.0.1) 18.42ms referer=http://localhost:8880/tree
    [I 10:37:19.390 NotebookApp] Creating new notebook in
    [W 10:37:19.410 NotebookApp] 403 POST /api/contents (172.17.0.1): Permission denied: Untitled.ipynb
    [W 10:37:19.410 NotebookApp] Permission denied: Untitled.ipynb
    [W 10:37:19.411 NotebookApp] 403 POST /api/contents (172.17.0.1) 21.50ms referer=http://localhost:8880/tree

    最佳答案

    第一的:

    docker run -d -p 8888:8888 -v $(pwd):/srv gw000/keras-full

    上面的命令是使用“ pwd ” Linux 命令(“ pwd ” 如打印当前目录)挂载当前目录到文件夹“ /srv ”容器内。它与更改密码无关。

    第二:

    在我看来,您正在使用文件夹“ c:/Jupyter ”安装到容器文件夹中。您可能需要以管理员身份运行 Docker,或者您可以从不需要管理员权限的其他驱动器(如驱动器 d:/)挂载。
    那么你可以试试:
    docker run -d -p 8888:8888 -v d:/Jupyter:/srv gw000/keras-full

    看到后 Dockerfile https://hub.docker.com/r/gw000/keras-full/dockerfile ,我认为您的 Docker 正在安装 /srv 作为“ root ”用户并且服务在用户“ 用户”下运行,因此您必须通过 docker exec -it <name_or_id_of_container> bash执行到容器中并运行 chown -R user:user /home/user /srv

    关于docker - 如何使用 docker 镜像为 Jupyter notebook 挂载本地文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56037956/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com