Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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 (i.e. mkdir new_folder in the working directory will not add new_folder to the notebook's tree).

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!

like image 845
dannybess Avatar asked Sep 16 '18 20:09

dannybess


1 Answers

Docker containers have an isolated file system. 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.

If you want to give the container access to one folder in the host, you can use the option -v when running the docker.

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_CONTAINER_FOLDER is the mountpoint of the folder in the container file system (e.g., /home/username/work where username is the name of the user in the container).

The path in the container depends on the docker image that you are using. 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:

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.

like image 189
Amedeo Avatar answered Nov 16 '22 03:11

Amedeo