Skip to content

pg_database issue when admin db is missing #854

@jwillmer

Description

@jwillmer

As described in this issue comment the execution of the following command returns an exception if no database called admin exists.

bash-5.0# export PGPASSWORD=$DB_PASS
bash-5.0# psql -h $DB_HOST -U $DB_USER -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;' 
psql: error: FATAL:  database "admin" does not exist

Using the following docker-compose file will create me a new postgres container with missing admin database. I think an admin db should be added automatically to make the above command work.

postgres:
    image: postgres:12.1-alpine
    hostname: postgres
    container_name: postgres
    restart: always
    environment:
       POSTGRES_USER: ${POSTGRESUSER}
       POSTGRES_PASSWORD: ${POSTGRESPW}
       POSTGRES_DB: ${POSTGRESDB}
    volumes:
      - postgres-data:/var/lib/postgresql/data

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions