Running a repo2docker built container pushed to Dockerhub on Linux running docker causes a “permission denied” error when trying to create / save a notebook in a shared volume directory, apparently because directories mounted inside the container (eg
-v $PWD:/home/jovyan/notebooks) is owned by root.
docker exec -u 0 mycontainer chown -R jovyan /home/jovyan
on host fixes the permissions and allows notebooks to be saved.
Is there a way to start the container that doesn’t require this fix?
The Jupyter docker-stack images include support for changing the ownership of
$HOME when run as root, but repo2docker uses it’s own base image that doesn’t include that script. You could perhaps use a
Though you’d need to start your repo2docker container as
Otherwise you’ll have to chown
to whatever UID you’re using inside the repo2docker image before you run your container.
I’ve found one workaround is to start the container with –user 1234, which lets me copy stuff from host into the container, and the docker exec command to reset the mounted dir own which lets me save notebooks to the shared folder inside the container.
Not ideal, but it seems to work.
What I’ve been trying to find is a workflow that lets me build an image that I can run locally or that can equally be used directly in a jupyterhub / dockerspawner setting. My current workflow has the image defined using a .binder config in a Github repo, and a repo2docker/dockerhub action so I can:
- run the envt in MyBinder
- build and push an image via the repo2docker/dockerhub action
And then either use the image locally (tested) or (hopefully) directly in a jupyterhub/dockerspawner envt.
Is specifying a group-id either as part of
docker run or
repo2docker an option? That way you could have a UID that works with mybinder and a GID that works locally, or vice-versa.