Skip to content

FATAL: database does not exist [docker compose] #403

@sztwiorok

Description

@sztwiorok

We have docker compose.yml

version: '2'
services:
 postgres:
 image: "library/postgres:latest"
 environment:
 - POSTGRES_USER=test
 - POSTGRES_PASSWORD=qwerty
 - POSTGRES_DB=mydb

execute:

docker-compose up
docker exec -it <CONTAINER_ID> /bin/bash
psql -U test

and we get this error:

psql: FATAL: database "test" does not exist

Everything works fine witout compose

docker run -it -e POSTGRES_USER=test -e POSTGRES_PASSWORD=qwerty -e POSTGRES_DATABSE=mydb postgres
docker exec -it <CONTAINER_ID> /bin/bash
psql -U test

results:

root@cb18469bc86e:/# psql -U test
psql (10.1)
Type "help" for help.

test=# 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions