5

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?

2
  • Does docker logs container-name say anything? I might just run docker run rather than splitting docker create and docker start, but it shouldn't make a difference here. Commented Jun 30, 2020 at 18:24
  • I didn't know about the command docker logs container-name. I can solve it now myself! I'll write the answer as a separate answer. Thank you so much!! Commented Jun 30, 2020 at 18:27

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.