Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounting volume to a directory in $NB_USER breaks init.sh #1

Closed
njacobson-nci opened this issue Mar 30, 2023 · 9 comments
Closed

Mounting volume to a directory in $NB_USER breaks init.sh #1

njacobson-nci opened this issue Mar 30, 2023 · 9 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@njacobson-nci
Copy link

It appears that mounting a volume to $NB_USER/work will cause a failure in before-notebook.d init.sh.

The only change between these two commands is the volume mounting location inside the container. I removed everything except the bare minimum from the commands I'm running to see what causes the failure. Even explicitly setting the workdir to /home/njacobson or /home/jovyan fails.

It's not an unworkable issue, but it is strange and it's not specific to the work/ folder name. Figure it's worth documenting at least so others don't have to debug it.

Love the repo though, really great work.

docker run --gpus all -it -p 8888:8888 --user root -e NB_USER="njacobson" -v /home/nvadmin/data:/home/njacobson/work/ jupyterlab/cuda/python/scipy:latest
Entered start.sh with args: jupyter lab
/usr/local/bin/start.sh: running hooks in /usr/local/bin/start-notebook.d as uid / gid: 0 / 0
/usr/local/bin/start.sh: running script /usr/local/bin/start-notebook.d/populate.sh
/usr/local/bin/start.sh: done running hooks in /usr/local/bin/start-notebook.d
Updated the jovyan user:
- username: jovyan       -> njacobson
- home dir: /home/jovyan -> /home/njacobson
Ensuring /home/njacobson is owned by 1000:100 
/usr/local/bin/start.sh: running hooks in /usr/local/bin/before-notebook.d as uid / gid: 0 / 0
/usr/local/bin/start.sh: running script /usr/local/bin/before-notebook.d/init.sh
mv: cannot stat '.local/share/code-server/User/settings.json': No such file or directory
docker run --gpus all -it -p 8888:8888 --user root -e NB_USER="njacobson" -v /home/nvadmin/data:/home/njacobson/ jupyterlab/cuda/python/scipy:latest
Entered start.sh with args: jupyter lab
/usr/local/bin/start.sh: running hooks in /usr/local/bin/start-notebook.d as uid / gid: 0 / 0
/usr/local/bin/start.sh: running script /usr/local/bin/start-notebook.d/populate.sh
/usr/local/bin/start.sh: done running hooks in /usr/local/bin/start-notebook.d
Updated the jovyan user:
- username: jovyan       -> njacobson
- home dir: /home/jovyan -> /home/njacobson
Populating home dir /home/njacobson...
Success!
Ensuring /home/njacobson is owned by 1000:100 
/usr/local/bin/start.sh: running hooks in /usr/local/bin/before-notebook.d as uid / gid: 0 / 0
/usr/local/bin/start.sh: running script /usr/local/bin/before-notebook.d/init.sh
/usr/local/bin/start.sh: done running hooks in /usr/local/bin/before-notebook.d
Running as njacobson: jupyter lab
....
@benz0li
Copy link
Member

benz0li commented Mar 30, 2023

It appears that mounting a volume to $NB_USER/work will cause a failure in before-notebook.d init.sh.

If "${NB_USER}" != "jovyan", any folder mounted in "/home/${NB_USER}" will prevent the startup from succeeding.

👉 This is because of

# The home directory could be bind mounted. Populate it if it is empty

The bind mounted home directory is only populated if it is empty.

@benz0li
Copy link
Member

benz0li commented Mar 30, 2023

That's one of many reasons why I'm building my own Jupyter docker stack incorporating the changes listed above and mounting the entire home directory.

jupyter/docker-stacks#1478

@benz0li
Copy link
Member

benz0li commented Mar 30, 2023

Figure it's worth documenting at least so others don't have to debug it.

Will do.

@njacobson-nci
Copy link
Author

That also precludes having any data in the host mounting location as well. Is the solution to mount a working directory to another location?

@benz0li
Copy link
Member

benz0li commented Mar 31, 2023

That also precludes having any data in the host mounting location as well.

Correct. Bind mounting is only supported for empty folders.

Is the solution to mount a working directory to another location?

I suggest mounting any other [host] folder as a subfolder of /mnt in the container.
ℹ️ Filesystem Hierarchy Standard > ... > 3.12. /mnt : Mount point for a temporarily mounted filesystem

@benz0li
Copy link
Member

benz0li commented Mar 31, 2023

I had the following in mind:

  • Mounting the entire home directory preserves
    1. user specific configuration files for applications ("dot files/directories") and
    2. user generated content that only the user is supposed to have access to.
  • ~/projects is the so called working directory.
    1. Every project (e.g. git repository) should be placed in its own subfolder.
    2. My credo and advice: Projects should contain only code and no data1.
  • Data should be provided in separate locations.
    1. As subfolders of /mnt, in data bases, via Hadoop, via Spark, etc.
    2. Access rights to the data can thus also be managed separately.

Footnotes

  1. An exception may be made for small sample data sets.

@benz0li benz0li added bug Something isn't working documentation Improvements or additions to documentation labels Mar 31, 2023
@benz0li benz0li self-assigned this Mar 31, 2023
@benz0li
Copy link
Member

benz0li commented Apr 3, 2023

@njacobson-nci
Copy link
Author

Yeah thanks for documenting that!

@benz0li
Copy link
Member

benz0li commented Feb 23, 2024

Bind mounting a subfolder of the home directory is only possible for images with Python version ≥ 3.12.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants