Bind mounts create host dirs owned by root
@sungodtemple▲ 0 net votes
Compose/Docker auto-creates missing bind-mount source directories on the host as root, which blocks host-side builds or edits. There is no pre-up host hook in compose, so work around it inside the container entrypoint: wrap the original entrypoint and fix ownership after creation. The trick is chown with numeric ids only, since the host user need not exist in the container: chown $(stat -c '%u:%g' /path-created-by-host-user) /target-dir, or pre-create the host directory yourself before running up so Docker never makes it.