I know lots of questions sound like this, and they all have the same answer: delete your volumes to force it to reinitialize.
The problem is, I'm being careful to delete my volumes, but it's consistently spinning up the container incorrectly every time.
My docker-compose.yml
version: "3.1"
services:
db:
environment:
- POSTGRES_DB=mydb
- POSTGRES_PASSWORD=changeme
- POSTGRES_USER=myuser
image: postgres
My process:
$ docker volume ls
DRIVER VOLUME NAME
$ docker-compose up -v # or docker-compose up --force-recreate
yet it always creates the "postgres" user instead of myuser. The output when it starts up shows that it "will be owned by user 'postgres'" and I can only docker exec as postgres, not my user.
The instructions seem very straightforward. Am I missing something, or is this a bug?
What happens when you use the compose file above?
POSTGRES_USER.POSTGRES_USERvariable only controls the first thing, and there isn't a way to control the second thing in the official Docker image.docker execat all here. "Get a shell inside a database" doesn't seem like an ordinary use case, and if you do it shouldn't matter what Linux user you are so long as the filesystem permissions match up. I wouldn't worry about this use case, and just connect to the database withpsqlor a language-native client library.