plebnet-playground-docker icon indicating copy to clipboard operation
plebnet-playground-docker copied to clipboard

run containers as host user

Open asherp opened this issue 4 years ago • 8 comments

Adding user: ${user} to a docker-compose service will allow you to run a service with the host's username. This allows files created within the container to have the same permissions as the host. This would resolve issues with not being able see the contents of mounted volumes.

asherp avatar Aug 31 '21 01:08 asherp

Found this recommendation courtesy of the manim community:

For Linux users there might be permission problems when letting the user in the container write to the mounted volume. Add --user="$(id -u):$(id -g)" to the docker CLI arguments to prevent the creation of output files not belonging to your user.

asherp avatar Sep 04 '21 22:09 asherp

doesn't work, because the containers themselves won't have the local user, have it a try and its a hot mess.

rsafier avatar Sep 09 '21 20:09 rsafier

There is a way to do it but yeah... it would take a big lift... Maybe a medium/long term goal...

RandyMcMillan avatar Sep 09 '21 22:09 RandyMcMillan

https://github.com/RandyMcMillan/docker.shell This repo has an implementation of a user pushed to the container for reference.

RandyMcMillan avatar Sep 09 '21 22:09 RandyMcMillan

Do we still want to do this?

RandyMcMillan avatar May 15 '22 13:05 RandyMcMillan

I am not super concerned with it, but it writing out files as root can be confusing for users that don't have firm understanding of permissions under a non-root under Linux, so it is still probably worth doing (tho would hate to bust any existing that upgrade and now the container cannot read the mapped files they originally were written as root on host system) Seems the OSX defaults just give non-root users access to those files anyways so they never notice a difference.

rsafier avatar May 15 '22 18:05 rsafier

I will mess around with a config that defaults to root but allows for a user=user_name option.

RandyMcMillan avatar May 16 '22 01:05 RandyMcMillan

i know how to do this... i will take another look since I am doing some work on the playground...

RandyMcMillan avatar Dec 29 '22 14:12 RandyMcMillan