I'm sorry for the noob question. I try to run a PostgreSQL database in a container for tests. The commands:
docker create --name container-name -p 5432:5432 postgres
docker start container-name
Both commands work but when I check with
docker ps -a
It says, that the container stopped right after the start with exit code 1.
What am I doing wrong?
Thank you @David Maze for your comment.
With docker logs container-name
I was able to find out, that I got a way more detailed error message.
It says:
Error: Database is uninitialized and superuser password is not specified. You must specify POSTGRES_PASSWORD for the superuser. Use "-e POSTGRES_PASSWORD=password" to set it in "docker run". You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections without a password. This is not recommended. See PostgreSQL documentation about "trust": https://www.postgresql.org/docs/current/auth-trust.html`
This makes it clear for me, that I have to somehow preconfigure the container before I can start it.