-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Populate home dir if it is empty #1478
Comments
diff --git a/base-notebook/start.sh b/base-notebook/start.sh
index 05c1037..9e59ab2 100644
--- a/base-notebook/start.sh
+++ b/base-notebook/start.sh
@@ -123,6 +123,15 @@ if [ "$(id -u)" == 0 ] ; then
exit 1
fi
fi
+ # The home directory could be bind mounted. Populate it if it is empty
+ elif [[ "$(ls -A "/home/${NB_USER}" 2> /dev/null)" == "" ]]; then
+ _log "Populating home dir /home/${NB_USER}..."
+ if cp -a /home/jovyan/. "/home/${NB_USER}/"; then
+ _log "Success!"
+ else
+ _log "Failed to copy data from /home/jovyan to /home/${NB_USER}!"
+ exit 1
+ fi
fi
# Ensure the current working directory is updated to the new path
if [[ "${PWD}/" == "/home/jovyan/"* ]]; then
|
In my custom JupyterLab docker stack a duplicate of
#!/bin/bash
set -e
if [[ "$(ls -A "/home/jovyan" 2> /dev/null)" == "" ]]; then
cp -a /var/tmp/jovyan/. /home/jovyan
fi |
Which are the files here that you care about? Is your home directory totally empty, like missing |
Yes, the home directory is entirely empty if bind mounted to It's the whole content of |
For jupyters base-notebook this would take care about
For my custom jupyterlab image this would take care about
Only for the initial/first startup and if the mounted home directory at |
@consideRatio the merge seems to have unintentionally caused this issue to be closed prematurely. (Probably I shouldn't have had "close #1478" in my description! 😆) |
I find the suggestion of 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. |
Closing due to inactivity. |
@benz0li I do like this proposal (sorry I haven't answered 2 years ago 🙂). I think the best way for us would be to do the following:
I see 2 current issues, which will be solved by such a behaviour:
I checked that the example works fine though, because:
|
A fresh thought on this... Linux has a default template in |
@mathbunnyru Check the difference from https://github.com/b-data/jupyterlab-python-docker-stack/blob/e0295b86406246873f73d5bc5763866729d9c9d6/base/scripts/usr/local/bin/start.sh to the current file of this repository. I populate with https://github.com/b-data/jupyterlab-python-docker-stack/blob/e0295b86406246873f73d5bc5763866729d9c9d6/base/scripts/usr/local/bin/start-notebook.d/populate.sh using a |
Thanks @maresb, that's a good point. We have some files, which are more our image specific, like I don't know if we can actually use |
Thanks @benz0li! Could you please tell, how do you backup |
It's nice to see someone using our |
Using |
I originally wanted this done only in the so called base images of my JupyterLab docker stacks. There is one exception, though: https://github.com/b-data/jupyterlab-r-docker-stack/blob/3e81912c6763d0f198901ac0c19a5ce027cfa03f/qgisprocess/latest.Dockerfile#L249-L250 |
I actually changed my mind - I think it's better to manually backup files we want to preserve (like
|
Thanks @benz0li! |
If I remember correctly, the bind mounted home directory is not populated [with I am quite sure, that was the reason I copied to |
`> If I remember correctly, the bind mounted home directory is not populated. Yes, you're right, but we're calling |
@benz0li Also, if you can share issues (if you had any) or something we need to be aware of (when using such a backup approach), that would be great. As far as I understand, you don't manually change ownership of backup to new user (if NB_UID was manually set for example), which might not work, I suppose? (unless user runs with CHOWN_HOME). |
So, my plan is:
|
Bind mounting a home directory a quite delicate matter. My JupyterLab docker stacks allow bind mounting the same home directory by any image so the
Correct. See also https://github.com/b-data/jupyterlab-python-docker-stack#create-home-directory Use case: https://demo.jupyter.b-data.ch |
Correct. Exactly this example is the only exception. |
@mathbunnyru ℹ️ I found a way to enable bind mounting a subfolder of the home directory for arbitrary Users can now choose whether to (bind) mount the entire home directory or just a subfolder within it. |
@benz0li that's great, I see the issue this resolves. To be honest, I don't understand everything about your implementation (I am not great at shell scripting), though. Anyone who wants to implement a similar thing in this repo, it would be really nice (but we will have to add extensive testing). |
At our institution, we use this script, inserted at #!/bin/bash
set -e
if [[ ! -f "$HOME/.bashrc" ]] ; then
echo "no bashrc found in $HOME, restoring defaults";
cp /etc/skel/.bashrc $HOME;
cp /etc/skel/.profile $HOME;
cp /etc/skel/.bash_logout $HOME;
else
echo "bashrc found in $HOME";
fi |
@DeepCowProductions This is not about populating the user's home directory from This is about Therefore, b-data's/my own JupyterLab docker stack have |
What docker images this feature is applicable to?
jupyter/base-notebook
What changes do you propose?
Populate home dir if it is empty.
How does this change will affect users?
If a user mounts to
/home/{raw_username}
it will be populated from/home/jovyan
on initial startup.ℹ️
NB_USER
set to{raw_username}
; the unescapedusername
(e.g. from JupyterHub).The text was updated successfully, but these errors were encountered: