D
D
Dzhemchik2020-04-14 23:54:03
PostgreSQL
Dzhemchik, 2020-04-14 23:54:03

How to enter password for postgres via docker?

Hello! Help to understand please.
I am running django and postgresql with docker-compose.
Contents of docker-compose.yml:

version: '3'

services:
  web:
    build: ./t_kontakta
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
      - ./t_kontakta:/data
    ports:
      - "8000:8000"
    depends_on:
      - db
  db:
    image: postgres
    restart: always
    environment:
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=postgres


On a Mac, I imported the postgres database with the following command:
docker-compose run --rm db pg_dump -h db -U postgres postgres > database.sql

In response, he asked for a password, and successfully uploaded all the data to a file.
On another device (on Windows), I am now trying to load data into the database with the command:
docker-compose run --rm db psql -h db -U postgres postgres < database.sql

In response, swearing:

Password for user postgres:
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anikavoi, 2020-04-18
@anikavoi

https://www.postgresql.org/docs/11/libpq-envars.html
Maybe not POSTGRES_PASSWORD but PGPASSWORD ?
Is this type of authentication for this address mentioned in pg_hba?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question