Docker volume option create folder as "root" user

Solution 1:

As discussioned here, this is an expected behavior of docker. You can create the target volume directory before running docker command or change the owner to your current user after the directory is created by docker:

chown $(whoami) -R /path/to/your/dir

Solution 2:

I hit this same issue (also in a genomics context for the very same reason) and also found it quite unintuitive. What is the recommended way to "inherit ownership". Sorry if this described elsewhere, but I couldn't find it. Is it something like:

docker run ... -u $(id -u):$(id -g) ...