Reputation: 41
How do I make sure a Docker user is added to a specific group when running a container?
This is my situation. I'm running a Docker container where i need to access /dev/video0 which is owned by "root" and in group "video" on the host.
My host UID is 1000 and gid=1000 and I'm in the "video" group (gid=44). When I run the following Docker run command, the user with gid=1000 inside the container isn't added to the video group. I have to execute a command inside the container to add the user to the video group and then everything works.
docker run \
--name=cloud9 \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=US/Eastern \
-p 8000:8000 \
-v /home/pi/code:/code `#optional` \
--group-add 44 \
--device=/dev/video0 \
--restart unless-stopped \
linuxserver/cloud9
How do I add user with uid=1000 to group 44 ('video') directly from the run command?
Upvotes: 0
Views: 3204
Reputation: 1176
Try this:
docker run \
--name=cloud9 \
--user=1000:44 \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=US/Eastern \
-p 8000:8000 \
-v /home/pi/code:/code `#optional` \
--group-add 44 \
--device=/dev/video0 \
--restart unless-stopped \
linuxserver/cloud9
Upvotes: 0