I tried what the post indicated The other answer ..., but it didn't work, the error kept appearing.
So I found this article, where I used "Option 2: Use a Docker Volume Instead of a Bind Mount", PostgreSQL: How to resolve “Permission denied” when bringing up service in Docker container — ep2
services:
db:
image: postgres:latest
container_name: postgres_db
environment:
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: mydatabase
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
driver: local