A fresh postgres:15 won't stay up. It exits within seconds, every time. The compose file bind-mounts the data directory from the host (/srv/postgres-data), and the database was supposed to persist there.
The password env is set correctly and the image is fine — but the container keeps dying on startup. Read what postgres is actually complaining about and get a working database running with persistent storage.
db — postgres:15, Exited (1), data dir bind-mounted from the host/srv/postgres-data.
$ docker logs db
chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted
...
initdb: error: could not change permissions of directory
"/var/lib/postgresql/data": Operation not permitted
$ docker inspect -f '{{range .Mounts}}{{.Type}} {{.Source}} -> {{.Destination}}{{end}}' db
bind /srv/postgres-data -> /var/lib/postgresql/data
You've solved it when:
-v pgdata:/var/lib/postgresql/data),
or the host dir after chown 999:999 /srv/postgres-data.
docker CLI only.status == running with a data volumepostgres image,chmod 777 on the data dir a tempting but wrong "fix"?