-
Im new to docker and databases and im quite confused what the POSTGRES_HOST value should be. I kept getting hung on listening for post 8080 and I think this is issue because it is not able to connect. Thank you for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
@Jackbaude That's the name of your container where PostgreSQL running, I usually call them
|
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
I am still having issues though with it saying that it could not connect to it. I am using podman, since I'm on fedora, but that doesn't make a difference since they run identical. Am I missing something? CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30211bf0fa25 docker.io/library/postgres:latest postgres 2 seconds ago Up 2 seconds ago 0.0.0.0:5432->5432/tcp wikidb [Jakku@localhost ~]$ podman run -u postgres:postgres -e POSTGRES_HOST=wikidb -e POSTGRES_DB=wiki -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e SCHEDULE="@every 1s" prodrigestivill/postgres-backup-local
2021/02/05 18:43:13 Running version: v0.0.9
2021/02/05 18:43:13 new cron: @every 1s
2021/02/05 18:43:13 Opening port 8080 for health checking
2021/02/05 18:43:14 14 cmd: /backup.sh
2021/02/05 18:43:14 14: Creating dump of wiki database from wikidb...
2021/02/05 18:43:14 14: pg_dump: error: connection to database "wiki" failed: could not translate host name "wikidb" to address: Name or service not known
2021/02/05 18:43:14 14 Exit Status: 1 EDIT: Here is my podman/docker command as well podman run -p 5432:5432 -d --name wikidb \
-e POSTGRES_PASSWORD=pass \
-e POSTGRES_USER=user \
-e POSTGRES_DB=wiki \
-v pgdata:/var/lib/postgresql/data \
postgres |
Beta Was this translation helpful? Give feedback.
-
As stated in the issue #39, in order to use the docker name you need to have both conainers in at least one common network. My recommendation is that you use a docker-compose file inspired by the example in the README.md file or inspired by the example above provided by @sigrlami. In case you want to use podman, please refer to the podman documentation how to allow connectivity between different containers. |
Beta Was this translation helpful? Give feedback.
-
Thank you! podman pod create -n poddy -p 8080:8080,5432:5432
podman ps -a --pod
podman run -dt --pod poddy --rm --name postgres-wiki -e POSTGRES_PASSWORD=pass -e POSTGRES_USER=user -e POSTGRES_DB=wiki postgres
podman run --pod poddy --rm -u postgres:postgres -e POSTGRES_HOST=postgres-wiki -e POSTGRES_DB=wiki -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e prodrigestivill/postgres-backup-local Of course change the names of the database, user,pass and the pod to what you need them to be. |
Beta Was this translation helpful? Give feedback.
@Jackbaude That's the name of your container where PostgreSQL running, I usually call them
<app-name>-db
. For example, look how namestremma-ai-db
shows up on docker-compose.yaml: