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

Run docker container as non-root user #152

Open
kidwellj opened this issue Aug 28, 2022 · 2 comments
Open

Run docker container as non-root user #152

kidwellj opened this issue Aug 28, 2022 · 2 comments

Comments

@kidwellj
Copy link

It's my understanding that running docker containers as root isn't ideal. The current configuration, which runs internally as www-data and externally as root can create some problems with access to permissions on the /music folder, and it's rather difficult to change the user after the container has been created, so this can't be sorted by simply adding a docker compose line user: $UID:$GID as subsequent access to the contents of the container by www-data (or whatever) is broken. It seems to me that it would be relatively trivial to map www-data onto a custom UID which could then, by extension, map onto a user account on the host OS. Has there been discussion on this before and perhaps some options ruled out? I'm happy to add a pull-request, but am aware there are several was to do it.

@phanan
Copy link
Member

phanan commented Aug 30, 2022

I admittedly am no Docker expert, so feel free to send a PR over if you think this is something that can use some improvements :)

@martijnende
Copy link

For those who came across the same issue, here is what I did to run everything as a local user (let's call it asterix, with uid=1000,gid=1000):

  1. Get the source files from Github.
  2. Modify Dockerfile, adding RUN useradd --groups www-data --password asterix --no-create-home asterix and changing chown www-data:www-data into chown asterix:asterix. Make sure to do the useradd before any chown is executed.
  3. In the docker compose file, replace image: phanan/koel with:
build:
  - context: .
  - dockerfile: "Dockerfile"
  1. Also in the compose file, add user: "1000:1000" to all services.
  2. For the first run, use docker exec --user asterix -it <container_name_for_koel> bash.

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