How to fix error "Error: Database is uninitialized and superuser password is not specified."
Feb 26
Hello i get this error after i run docker-compose build up
But i get this error postgres_1 | Error: Database is uninitialized and superuser password is not specified.
Here is a snap shot of the error!
And down below is my docker-compose.yml file
version: '3.6'
Server.js fileservices:
smart-brain-api:
container_name: backend
build: ./
command: npm start
working_dir: /usr/src/smart-brain-api
ports:
- "3000:3000"
volumes:
- ./:/usr/src/smart-brain-api
#PostGres Database
postgres:
image: postgres
ports:
- "5432:5432"
1 answer
Accepted answer · original discussion
Feb 26
To avoid that you can specify the followings environments variables for postgres container on your docker-compose file.
POSTGRES_PASSWORD This environment variable is normally required for you to use the PostgreSQL image. This environment variable sets the superuser password for PostgreSQL. The default superuser is defined by the POSTGRES_USER environment variable.
POSTGRES_DB This optional environment variable can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value of POSTGRES_USER will be used.
For more information about Environment Variables check: https://hub.docker.com/_/postgres
2 question comments
Use comments to ask for clarification. Post a solution as an answer.
Feb 26
Jul 22
docker-compose.yml nor Dockerfile on my desktop. Where to put the POSTGRES_HOST_AUTH_METHOD: "trust"? And is my assumption that the postgres runs inside that container right or is there a problem that the host system should run it?