I cannot create PostgreSQL container with shared volume on macOS

I am using Docker on macOS 12.3 with the options:
Use the new Virtualization framework
Enable VirtioFS accelerated directory sharing

I am trying to create a PostgreSQL container:

mkdir -p ~/Developer/postgres_data

docker run -d --name postgres -p 5432:5432 --platform linux/arm64/v8 -e POSTGRES_PASSWORD=postgres -v /Users//Developer/postgres_data:/var/lib/postgresql/data postgres:13

But starting this container fails with:

docker logs postgres

The files belonging to this database system will be owned by user “postgres”.

This user must also own the server process.

The database cluster will be initialized with locale “en_US.utf8”.

The default database encoding has accordingly been set to “UTF8”.

The default text search configuration will be set to “english”.

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data … ok

creating subdirectories … ok

selecting dynamic shared memory implementation … posix

selecting default max_connections … 100

selecting default shared_buffers … 128MB

selecting default time zone … Etc/UTC

creating configuration files … ok

2022-03-30 19:25:49.792 UTC [40] LOG: could not open file “pg_wal/000000010000000000000001”: No such file or directory

2022-03-30 19:25:49.792 UTC [40] FATAL: could not open file “pg_wal/000000010000000000000001”: No such file or directory

child process exited with exit code 1

initdb: removing contents of data directory “/var/lib/postgresql/data”

running bootstrap script … %


I have the same issue. Anyone from PostgreSQL or Docker can help?

I have the same issue. Did you find how to fix?

I didn’t. I’m using Podman on Linux now.

I had this same issue and resolved it by disabling VirtioFS accelerated directory sharing.

After that, I removed the previous container, cleared the mounted directory from my host machine, and restarted the container, and it started up fine. Something about the startup process of postgres doesn’t play nice with VirtioFS. But previously I had a long-running postgres container that was working fine with VirtioFS enabled, given that I had initialized the database with VirtioFS disabled. ¯\_(ツ)_/¯


If you are still facing the issue, try upgrading your macOS to the latest 12.4.
I tested it in my machine with Docker Desktop for Mac 4.8.2 with VirtioFS enabled and it is now working like a charm.

1 Like