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

PermissionError: [Errno 13] Permission denied #46

Open
pinq- opened this issue May 17, 2021 · 3 comments
Open

PermissionError: [Errno 13] Permission denied #46

pinq- opened this issue May 17, 2021 · 3 comments

Comments

@pinq-
Copy link

pinq- commented May 17, 2021

Hi
I'm trying to run this docker with this composer:

  mopidy:
    container_name: mopidy
    image: wernight/mopidy
    volumes:
      - ${USERDIR}/kontit/mopidy/local:/var/lib/mopidy/local
      - ${USERDIR}/kontit/mopidy/config:/var/lib/mopidy/.config/
      - /run/user/{$PUID}/pulse:/run/user/105/pulse:ro
    ports:
      - 6600:6600
      - 6680:6680
    user: ${PUID}:${PGID}

But when I try to run it, I get this error in the logs:

Traceback (most recent call last):
  File "/usr/bin/mopidy", line 11, in <module>
    load_entry_point('Mopidy==3.1.1', 'console_scripts', 'mopidy')()
  File "/usr/lib/python3/dist-packages/mopidy/__main__.py", line 62, in main
    create_core_dirs(config)
  File "/usr/lib/python3/dist-packages/mopidy/__main__.py", line 157, in create_core_dirs
    path.get_or_create_dir(config["core"]["config_dir"])
  File "/usr/lib/python3/dist-packages/mopidy/internal/path.py", line 23, in get_or_create_dir
    dir_path.mkdir(mode=0o755, parents=True)
  File "/usr/lib/python3.7/pathlib.py", line 1251, in mkdir
    self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/var/lib/mopidy/.config/mopidy'

The user is in the docker group and all the other container are working. Any idea what to do?

@nefastosaturo
Copy link

Hello, I'm trying to make it work as you. As I understood it correctly, when you run the container as your user to give access to the pulse folder, then you are trying to run "mopidy" not as mopidy-user but as you. So I think that is needed to give the same mopidy permission to the user passed as parameter when launching the container.

I was looking at the TheBiggerGuy example here for creating a new user but I'm not quite sure how to do it. If I can make it work, I'll write back

@nefastosaturo
Copy link

Ok, well I found a solution, maybe not the cleanest one.

I've built another Dockerfile on top of the one provided by this repo adding a new user inside the group 29 (audio) and then give it some permissions

the dockerfile:

FROM wernight/mopidy

USER root

ARG USER_ID

ENV HOME=/var/lib/mopidy
RUN set -ex \
 && adduser --disabled-password --gecos '' --uid $USER_ID --gid 29 user \
 && usermod -G audio,sudo user \
 && chown user:audio -R $HOME /entrypoint.sh \
 && chmod go+rwx -R $HOME /entrypoint.sh

USER mopidy

ENTRYPOINT ["/usr/bin/dumb-init", "/entrypoint.sh"]
CMD ["/usr/bin/mopidy"]

HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
    CMD curl --connect-timeout 5 --silent --show-error --fail http://localhost:6680/ || exit 1

docker build command:

docker build -f <custom_dockerfile> -t mopidy/localuser --build-arg USER_ID=$(id -u) .

and then run:

docker run --rm -it \
-p 6600:6600 -p 6680:6680 \
-v /run/user/$UID/pulse:/run/user/105/pulse \
-v <insert here other volumes for media files> mopidy/localuser

@DeadEnded
Copy link
Contributor

Just to expand on this...

I have spent the last two days trying to get this containers permissions working.

If don't map the local and media directories and let the container create them... they are created as root and I get permission errors (creating the images folder etc.).

If I map the local and media directories they get the permissions of what I set on the host (I have to create the images directory too or it fails to create) - this gets things working initially...

I tried to map playlists and m3u directories to make them persistent (not sure why they aren't? - wouldn't you lose playlists on container recreation?) and now that fails. Unmapped it fails, mapped it fails - this is using the Mopidy-Iris web extension I used Mopidy-MusicBox-Webclientand was able to get a playlist created... but not with Mopidy-Iris.

Overall my impression has been... permissions are a cluster... at least for me. I have had nothing but trouble getting permissions straightened out... seems like it's a constant battle and the only thing that seems to work constantly is just running as root... which is NOT ideal...

DeadEnd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants