Docker Community Forums

Share and learn in the Docker community.

How can I create a docker container for postgres without password?

I have a docker container where I’m running the command like this to make a container

docker run -d -i --name postgres3 -p 5432:5432 -e POSTGRES_PASSWORD="" postgres:9.6.23

I ran this command and it’s creating the container but I’m having an issue with starting the container.

So what can I do here?

I just need to create a container that has no password

Have you read the description on Docker Hub? You always should start with that:

Docker Hub: postgres

See POSTGRES_HOST_AUTH_METHOD set to trust. It is actually in the container logs when you start it without a non-empty password.

Error: Database is uninitialized and superuser password is not specified.
       You must specify POSTGRES_PASSWORD to a non-empty value for the
       superuser. For example, "-e POSTGRES_PASSWORD=password" on "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.htm

So you have to things you should always do. Reading the README/documentation and checking logs.