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

Permission denied when mounting local folders #885

Open
ejgutierrez74 opened this issue Jun 17, 2019 · 4 comments

Comments

@ejgutierrez74
Copy link

commented Jun 17, 2019

What docker image you are using?

Example: jupyter/all-spark-notebook

What complete docker command do you run to launch the container (omitting sensitive values)?
docker run -it --rm -p 8888:8888 -v /home/eduardo/Descargas/DockerSpark/:/home/jovyan/work -w /home/jovyan/work jupyter/all-spark-notebook

What steps do you take once the container is running to reproduce the issue?
Permission denied when mounting local folders. I tried everything related to files: upload a file from filesystem, save a notebook, access a dataset in the same folder and i cant...

Example:

  1. http://(869fbf0e4bbe or 127.0.0.1):8888/?token=d5f852e4322a7daccd8cc380d6199d2a3d071789d7ef9b60

imagen

What do you expect to happen?

Access files

What actually happens?
Error permission denied

Im using Ubuntu 18.04 LtS

eduardo@MiPcLinux:~/Descargas/DockerSpark$ docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.4
 Git commit:        e68fc7a
 Built:             Tue May  7 17:57:34 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       e68fc7a
  Built:            Tue May  7 17:57:34 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Than ks in advance

@ejgutierrez74

This comment has been minimized.

Copy link
Author

commented Jul 8, 2019

Any help ??

@felipebn

This comment has been minimized.

Copy link

commented Jul 25, 2019

Hey @ejgutierrez74,
Not sure if you managed to solve your issue, but I was having the same.

After reading the docs (https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html) I was able to get it running with the following env options:

docker run --rm -p 8888:8888 --name jupyter -e NB_USER=felipebn -e CHOWN_HOME=yes -e CHOWN_EXTRA_OPTS='-R' --user root -w /home/felipebn/ -v "C:\Users\felipe.brandao\eclipse-workspace-2019-01\Project\jupyter":/home/felipebn/ jupyter/base-notebook 

Important parts are:

  • NB_USER: set to whatver username you want, but be aware to reuse it
  • CHOWN_HOME and CHOWN_EXTRA_OPTS to give appropriate permissions
  • --user root: requried to make these changes
  • -w /home/felipebn/: to set the working dir for the notebook (use whatever username you used in the NB_USER env var)

edit: removed the "work" ending as it would be set to root

@parente

This comment has been minimized.

Copy link
Member

commented Jul 27, 2019

The note associated with the -v flag under https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#docker-options likely explains what needs to be done to allow the within container notebook process access to your host mounted home directory.

@masip85

This comment has been minimized.

Copy link

commented Aug 22, 2019

Hello

I've had same problem. But that flags (-e NB_USER=vmasip -e CHOWN_HOME=yes -e CHOWN_EXTRA_OPTS='-R' --user root -w /home/vmasip/ ) collapse container, it cannot start:

Set username to: vmasip
Changing ownership of /home/vmasip to 1000:100 with options ''
Executing the command: jupyter lab --NotebookApp.password=********
[I 08:54:05.232 LabApp] [nb_conda_kernels] enabled, 2 kernels found
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'runtime_dir'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-lab", line 11, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</opt/conda/lib/python3.7/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
  File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 1676, in initialize
    self.init_configurables()
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 1349, in init_configurables
    connection_dir=self.runtime_dir,
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
    ensure_dir_exists(rd, mode=0o700)
  File "/opt/conda/lib/python3.7/site-packages/jupyter_core/utils/__init__.py", line 13, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/opt/conda/lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/conda/lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/conda/lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/opt/conda/lib/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/vmasip/.local'


Besides that, it makes (as documentation specifies) mounted drive folder change its permissions to root. I don't like this.
If I try to use the "silver bullet" of docker user and group options, it doesn't work because user and group must be specified in the Dockerfiles.

My solution:
I didn't like this from log:
Changing ownership of /home/vmasip to 1000:100 with options ''
Because (in my computer) user vmasip GID is 1000. Then I used this:
-e NB_GID=1000
Finally, log shows now:

Set username to: vmasip
Changing ownership of /home/vmasip to 1000:1000 with options ''
Add vmasip to group: 1000

Now it works, and my vmasip user in container belongs to users and vmasip groups (1000).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.