-
Notifications
You must be signed in to change notification settings - Fork 485
Closed
Description
When using the image with Docker Compose and accessing it with docker exec -it <container name> bash
and psql
, you will get this error message:
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist
I have tried to isolate the problem with the following:
- Using
docker run
to test and see if I can runpsql
just fine - Using the image with a
docker-compose.yml
of mine and psql sports the error. - Using the image as the only container in the docker-compose.yml and psql still sports the error
- Using the postgres [13] image and install postgis myself.
For #1, I ran the following command:
docker run --name some-postgis --net=aow-trips_sail -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=woopwoop -e PGPASSWORD=powpow -d postgis/postgis:13-master
Running psql
just works fine.
I won't go into detail with #2 as #3 might be more interesting. For #3, I had the following docker-compose.yml:
version: '3'
services:
pt-pgsql:
image: postgis/postgis:14-master
ports:
- '5432:5432'
environment:
PGPASSWORD: 'kylie'
POSTGRES_DB: 'test_db'
POSTGRES_USER: 'notroot'
POSTGRES_PASSWORD: 'kylie'
volumes:
- 'pgtest-pgsql:/var/lib/postgresql/data'
networks:
- pgtest
healthcheck:
test: ["CMD", "pg_isready", "-q", "-d", "test_db", "-U", "notroot"]
retries: 3
timeout: 5s
networks:
pgtest:
driver: bridge
volumes:
pgtest-pgsql:
driver: local
#4 works completely fine, but I won't go into detail into it as there are heaps of files involved. If any of you would like to have it, feel free to ask.
I have tested this with both 14-master
and 13-master
.
Being able to access psql from the container is very important as you will need this capability to export and import [very large] databases.
Metadata
Metadata
Assignees
Labels
No labels