I tried this by running docker run -it -e NB_UID=500 --rm -p 8888:8888 jupyter/scipy-notebook to launch the container, then docker exec -it <container_name> bash to connect to the container. When I look at /etc/passwd within the container, the jovyan user doesn't have the correct uid.
Looking at the revision history for start_singleuser.sh, it looks like some functionality to set up the user was removed. Is this option being deprecated?
The NB_UID is not being deprecated. The start_singleuser.sh script comes from JupyterHub and is not the script the containers launch by default for single-user containers. The option is still present in https://github.com/jupyter/docker-stacks/blob/master/base-notebook/start.sh
Just dawned on me what the problem is. From the README:
-e NB_UID=1000 - Specify the uid of the jovyan user. Useful to mount host volumes with specific file ownership. For this option to take effect, you must run the container with --user root. (The start-notebook.sh script will su jovyan after adjusting the user id.)
Add the --user root to your command and you should be good to go. Only root can usermod.
Most helpful comment
Just dawned on me what the problem is. From the README:
Add the
--user rootto your command and you should be good to go. Only root can usermod.