简体   繁体   English

远程Jupyter笔记本+ Docker - 不更新文件目录?

[英]Remote Jupyter Notebook + Docker — Doesn't Update File Directory?

I'm currently working with a remote Jupyter notebook (through a docker image), and am having an issue with finding a folder that exists in the directory (where I'm running the notebook) but doesn't exist in the notebook tree. 我目前正在使用远程Jupyter笔记本(通过docker镜像),并且遇到了查找目录中存在的文件夹(我正在运行笔记本)但在笔记本树中不存在的问题。

Command I'm using to execute the notebook: 命令我用来执行笔记本:

nvidia-docker run -it -p 8888:8888 --entrypoint /usr/local/bin/jupyter NAMEOFDOCKERIMAGE notebook --allow-root --ip=0.0.0.0 --no-browser

Command I'm using to access the notebook remotely: 命令我用来远程访问笔记本:

ssh -N -f -L localhost:8888:localhost:8888 remote_user@remote_host

What's weird is that if I navigate to the notebook's working directory (on the remote host / server) and add a folder + files, the notebook will not reflect the changes (ie mkdir new_folder in the working directory will not add new_folder to the notebook's tree). 有点奇怪的是,如果我导航到笔记本的工作目录(在远程主机/服务器上)并添加文件夹+文件,笔记本将不会反映更改(即工作目录中的mkdir new_folder不会将new_folder添加到笔记本的树中)。

Would anyone know why this could be the case, and if so, how to "refresh" / "update" the tree? 有谁会知道为什么会这样,如果是这样,如何“刷新”/“更新”树?

Thanks so much for all and any help! 非常感谢所有人和任何帮助!

Docker containers have an isolated file system. Docker容器具有独立的文件系统。 This means that the program running in the container (jupyter notebook in your case) sees different folders than the ones you have in the host system. 这意味着在容器中运行的程序(在您的情况下为jupyter notebook)看到的文件夹与您在主机系统中的文件夹不同。

If you want to give the container access to one folder in the host, you can use the option -v when running the docker. 如果要让容器访问主机中的一个文件夹,则可以在运行docker时使用选项 -v

In your case, you should run the container with this command: 在您的情况下,您应该使用此命令运行容器:

nvidia-docker run -it -p 8888:8888 -v /PATH_TO_HOST_FOLDER:/PATH_TO_CONTAINER_FOLDER --entrypoint /usr/local/bin/jupyter NAMEOFDOCKERIMAGE notebook --allow-root --ip=0.0.0.0 --no-browser

where: 哪里:

  • PATH_TO_HOST_FOLDER is the path of the folder in the host system that you want to share with the container. PATH_TO_HOST_FOLDER是主机系统中要与容器共享的文件夹的路径。

  • PATH_TO_CONTAINER_FOLDER is the mountpoint of the folder in the container file system (eg, /home/username/work where username is the name of the user in the container). PATH_TO_CONTAINER_FOLDER是容器文件系统中文件夹的挂载点(例如, /home/username/work ,其中username是容器中username的名称)。

The path in the container depends on the docker image that you are using. 容器中的路径取决于您正在使用的docker镜像。 If you do not know the path in the container, you can take a look at the container file system, by running a bash inside the container with this command: 如果您不知道容器中的路径,可以使用以下命令在容器内运行bash来查看容器文件系统:

nvidia-docker run -it --entrypoint /bin/bash NAMEOFDOCKERIMAGE 

After you run this command, you are in a bash inside the container, so you can see the inner filesystem with ls , pwd , etc. 运行此命令后,您将进入容器内的bash,因此您可以使用lspwd等查看内部文件系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM