11
submitted 9 months ago* (last edited 9 months ago) by sabreW4K3@lazysoci.al to c/docker@programming.dev

I'm trying to create a postgres container, I have the following in my Docker Compose:

db:
  container_name: db
  image: postgres
  restart: always
  environment:
    #POSTGRES_USER="postgres"
    POSTGRES_PASSWORD: HDFnWzVZ5bGI
  ports:
    - 5432:5432
  volumes:
    - pgdata:/var/lib/postgresql/data
adminer:
  container_name: adminer
  image: adminer
  restart: always
  ports:
    - 8338:8080

And yet Docker keeps saying that the database is initialized and that the superuser is not specified. Where am I going wrong?

I've tried with and without equals, a hyphen, quotation marks. No matter what I try, it won't see it.

#Solution:

Find:

  volumes:
    - pgdata:/var/lib/postgresql/data

Replace:

  volumes:
    - /opt/postgres/data:/var/lib/postgresql/data

More info: https://lazysoci.al/comment/8597610

you are viewing a single comment's thread
view the rest of the comments
[-] alphapuggle@programming.dev 3 points 9 months ago

Just took a quick look at my config file and I have

POSTGRES_USER: postgres

Note specifically the colon and lack of quotes.

It's also worth noting I'm using postgres:16-bullseye as my image. Something wasn't working right with latest when I was setting it up a few months ago, but I don't think it was the user. Regardless, worth a shot if the previous change doesn't help.

this post was submitted on 26 Mar 2024
11 points (92.3% liked)

Docker

966 readers
1 users here now

founded 2 years ago
MODERATORS