79393371

Date: 2025-01-28 09:59:48
Score: 1
Natty:
Report link

A third option on Linux (or on MacOS Intel if you install bindfs) in addition to the two in @Daniel t.'s answer is something I found in moby/moby#7198: use a host-side bind mount to rewrite the UID and GID, and then mount the target of that mount into your container.

For example:

sudo bindfs -u UID -g GID app app_chowned
docker run -d \
  -it \
  --name devtest \
  -v "$(pwd)"/app_chowned:/app \
  nginx:latest

All credit to jjrv on GitHub, the author of that comment.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Daniel
  • Low reputation (0.5):
Posted by: codermonkeyfuel