operating system: Windows10
tools: Docker for windows
Database: Postgresql 11
docker run --name pg -d -e POSTGRES_PASSWORD=123 -v e:/docker_data/pg:/var/lib/postgresql/data -p 5432:5432 postgres
mounting the folder generates the corresponding file after startup, but it will prompt that the permission problem is terminated. The sharing setting has been made before.
2018-08-14 03:19:29.050 UTC [1] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2018-08-14 03:19:29.050 UTC [1] HINT: The server must be started by the user that owns the data directory.
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... initdb: could not fsync file "/var/lib/postgresql/data/base/1": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base/12993": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base/12994": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/base": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/global": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_commit_ts": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_dynshmem": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/mappings": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical/snapshots": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_logical": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/members": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact/offsets": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_multixact": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_notify": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_replslot": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_serial": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_snapshots": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_stat": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_stat_tmp": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_subtrans": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_twophase": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_wal/archive_status": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_wal": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_xact": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data": Invalid argument
initdb: could not fsync file "/var/lib/postgresql/data/pg_tblspc": Invalid argument
ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
waiting for server to start....2018-08-14 03:20:27.013 UTC [39] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2018-08-14 03:20:27.013 UTC [39] HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Examine the log output.