4

I'm getting the following error with postgreSQL with docker-compose:

postgres_1 | 2021-11-26 18:02:47.131 UTC [138] FATAL: database "preferences" does not exist

Just run docker-compose up to reproduce the issue.

version: '2.4'

services:
  postgres:
    image: postgis/postgis:12-3.0
    ports:
      - '5432:5432'
    environment:
      - POSTGRES_DB=preferences
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
    volumes:
      - ./docker/postgres:/docker-entrypoint-initdb.d/
      - dev-postgres-data:/var/lib/postgresql/data

    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB']
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - dev
  
networks:
  dev:
    external: true

volumes:
  dev-postgres-data:
    external: true

5
  • I got the same error, have you ever solved it? Commented Apr 10, 2024 at 2:57
  • @banan3'14 I had to create a script which creates the DB manually. You can also use this image instead postgres hub.docker.com/_/postgres Commented Apr 12, 2024 at 12:55
  • Does this answer your question? Docker-Compose + Postgres: /docker-entrypoint-initdb.d/init.sql: Permission denied Commented Apr 12, 2024 at 17:41
  • I ended up doing the same thing (postgres) and it worked after many tries. I guess it's a duplicate then, I found another post where the OP wrote in the comments that they ended up creating a dockerfile, they pointed to the other post that I put in the closure suggestion. Here it was the original one stackoverflow.com/questions/71059557/…. If so please close the post, let's keep this site clean. Commented Apr 12, 2024 at 17:43
  • I don't remember getting Permission denied error. The DB just wasn't created. Commented Apr 16, 2024 at 8:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.