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 running the docker image #9

Open
Midnighter opened this issue Mar 27, 2018 · 4 comments
Open

Permission denied when running the docker image #9

Midnighter opened this issue Mar 27, 2018 · 4 comments

Comments

@Midnighter
Copy link
Contributor

Midnighter commented Mar 27, 2018

So, my local user is part of the docker group. That leads to the following situation when using the run command that mounts my local work and pytfa directories into the container:

My local user cannot be mapped to a user in the docker container. Thus /home/pytfa/work and /src/pytfa are owned by 1001:1001 and access is denied to the pytfa user.

Although it can be useful, of course, to mount volumes into the container I'd say it shouldn't be necessary for the functioning of the image. Unfortunately, it is necessary as pytfa won't be installed.

If you really want to keep this behavior, an entrypoint script might be the right way to go. See this comment.

@psalvy
Copy link
Member

psalvy commented Mar 28, 2018

I chose to mount the code like this because it is a common practice (although admittedly not universal) for development (see this thread).
Of course once we'll get to a production code an adequate COPY would be a better option.

@psalvy
Copy link
Member

psalvy commented Sep 19, 2018

I stumbled upon this in an unrelated project:
add the flags

-e PGID=<gid> -e PUID=<uid>

In the run command to export environment variables linked to your user and group.
You can get the relevant information with

id <your_username>

@Midnighter
Copy link
Contributor Author

docker run -e PGID=$(id -g) -e PUID=$(id -u)

That could be a great option.

@Midnighter
Copy link
Contributor Author

Midnighter commented Sep 19, 2018

That's probably similar to running the image as user:

docker run --user "$(id -u):$(id -g)"

I'll check if that conflicts with any other parts that require permissions for the original docker user.

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

2 participants