Mount directory r/w for non-root in docker container


If I:

docker run -v $(pwd):/home/foobar/data ...

my host’s working directory will show up in the container at /home/foobar/data owned by user root. But I’d like it to show up as owned by inside-container user foobar, so that user foobar (inside the container) can read and write to it like any other directory it owns, and that the changes show up in my working directory on the host.

I’ve been looking for a mount option for the run command (similar to mount -o uid=1234 ...) or such, but no luck.

This is Docker on the Mac.

Source: Docker Questions