You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows 10主机与Docker容器间持久化Jupyter Notebook

How to Share Jupyter Notebooks Between Windows 10 Host and Docker Container

Got it, let's sort this out! The problem you're hitting is that without setting up a file mount, all notebooks created inside the container live in the container's isolated filesystem—they'll vanish if you stop or delete the container. To keep your notebooks synced between your Windows host and the Jupyter container, you need to use a Docker bind mount to link a folder on your host to a folder inside the container.

Here's a step-by-step fix:

  1. Stop your current container (if it's running)
    First, find the ID of your running Jupyter container with:

    docker ps
    

    Then stop it using:

    docker stop <container-id>
    

    (You can also use docker stop $(docker ps -q --filter ancestor=jupyter/minimal-notebook) to stop it without looking up the ID manually.)

  2. Create a folder on your Windows host
    Make a dedicated folder to store your shared notebooks, for example:
    C:\jupyter-notebooks

  3. Launch the container with a bind mount
    Use this command to start the container, linking your host folder to the Jupyter container's default working directory (/home/jovyan/work):

    docker run -p 8888:8888 -v /c/jupyter-notebooks:/home/jovyan/work jupyter/minimal-notebook
    
    • The -v flag sets up the mount: the left side is your Windows host path (formatted for Docker as /c/... instead of C:\...), and the right side is the container directory where Jupyter saves files by default.
    • If you're using WSL2 with Docker, you can also use the WSL path like /mnt/c/jupyter-notebooks instead.
  4. Verify the setup
    Open Jupyter in your browser, create a new notebook in the work directory, save it, and check your Windows host's C:\jupyter-notebooks folder—you'll see the saved file there immediately.

Important Notes:

  • Docker File Sharing Permissions: Make sure Docker Desktop has access to your C drive. Go to Docker Desktop Settings > Resources > File Sharing, then check the box next to C: and apply changes.
  • Path Formatting: Always use forward slashes (/) for paths in the docker run command, even on Windows. Avoid backslashes unless you escape them (like C:\\jupyter-notebooks).
  • Custom Working Directory: If you want to use a different folder inside the container, just replace /home/jovyan/work with your target container path, but using the default work directory keeps things simple since it's the first folder Jupyter displays.

内容的提问来源于stack exchange,提问作者Riya Gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 19:37:27