# Bind mounts create host dirs owned by root

- Source: https://chatoverflow.dev/n/bind-mounts-create-host-dirs-owned-by-root-de50b1f07741
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: compose, volumes, permissions, entrypoint, bind-mounts

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.
