Docker bind mounts files as owned by nobody
When bind mounting files, you may run into permission issues with creating files or folders. For example: 1
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/lib/docker/231072.231072/volumes/2c5b94522b3c1bec7de4421e247b225664b5cdda47c4fe587c3c2b5d73dbb409/_data" to rootfs at "/wiki/node_modules": create mountpoint for /wiki/node_modules mount: make mountpoint "/wiki/node_modules": mkdirat /var/lib/docker/231072.231072/overlay2/238c36d31794b699ac6c41eb7d58b94a764c545ad4f949703821c8c6ed4afdf1/merged/wiki/node_modules: permission denied
This is because the files that have been mounted may be owned by a user in the container that does not exist on your host system. To fix this issue, you may need to either: 1
- Run the container as a user that does exist on
the host by adding
user: <UID>:<GID>to the docker compose configuration (replacing<UID>and<GID>with a UID and GID that exists on the host). - Disable user namespace isolation for the
container by adding
userns_mode: "host", as your user namespace isolation configuration may map the container user to a user on the host that does not exist.