docker postgres image - Failed to initialize, db service is unhealthy

Postgres container requires that postgres user be setup with password in order to start it due to security reasons. we can add the password to the PostgreSQL like following:

env:
  POSTGRES_PASSWORD: postgres

Now the container will be up. We can read more about it here Creating PostgreSQL service containers .


changing the docker version to:

postgres:11@sha256:85d79cba2d4942dad7c99f84ec389a5b9cc84fb07a3dcd3aff0fb06948cdc03b

solved it for me apparently with latest 11 version due to some security related changes we get this issue.