You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Postgres container fails to initialize when bind-mounting data directory due to permission errors on macOS #333
When running the official Postgres Docker container on macOS with a bind mount for the data directory, the container fails to initialize with permission errors:
chmod: /var/lib/postgresql/data: Operation not permitted
chown: /var/lib/postgresql/data: Operation not permitted
This causes the container to stop immediately after starting.
Expected behavior
The container should handle bind mounts on macOS gracefully, either by avoiding permission modifications that are not permitted or by documenting known limitations and workarounds.
Ideally, provide recommended best practices or guidance for macOS users mounting data directories to the Postgres container.
@Kaikaikaifang@raxracks This is expected behavior for PostgreSQL and container. IIRC it may also be an issue for mySQL and MariaDB.
With --volume/--mount in container, you're mounting exactly what you want to mount as a virtiofs share into your container. The problem occurs when you try to make your PG_DATA directory the same as the mount point, because virtiofs permissions are a little quirky there, and PostgreSQL, as you can see by your error messages, tries to modify permissions on the mount point and fails.
What you're trying works in Docker because you're sharing all of your filesystem with the linuxkit VM that Docker runs. When you create the container, the actual mount point is somewhere below the virtiofs mount point, and that gets Linux bind mounted from the VM filesystem into your container's filesystem.
As a workaround, try making your mount point /var/lib/postgresql:
Activity
raxracks commentedon Jul 14, 2025
I'm having the same issue on macOS 26 Beta 3 with the main branch (e09e932) using both --mount and --volume
jglogan commentedon Jul 16, 2025
@Kaikaikaifang @raxracks This is expected behavior for PostgreSQL and
container. IIRC it may also be an issue for mySQL and MariaDB.With
--volume/--mountin container, you're mounting exactly what you want to mount as a virtiofs share into your container. The problem occurs when you try to make your PG_DATA directory the same as the mount point, because virtiofs permissions are a little quirky there, and PostgreSQL, as you can see by your error messages, tries to modify permissions on the mount point and fails.What you're trying works in Docker because you're sharing all of your filesystem with the linuxkit VM that Docker runs. When you create the container, the actual mount point is somewhere below the virtiofs mount point, and that gets Linux bind mounted from the VM filesystem into your container's filesystem.
As a workaround, try making your mount point
/var/lib/postgresql:raxracks commentedon Jul 16, 2025
Oh thanks that worked
Kaikaikaifang commentedon Jul 16, 2025
LGTM! Thanks.
Kaikaikaifang commentedon Jul 16, 2025
Before try
/var/lib/postgresqlinstead of/var/lib/postgresql/data, you may need:feat(setup): add Apple `container` orchestrator for the storage stack