I have the following compose file
version: '3'
services:
db:
image: "postgres:12.4"
ports:
- "15432:5432"
env_file:
- ./db/database.env
volumes:
- ./db/data:/var/lib/postgresql/data
- ./db/init:/init
- ./db/init/run.sh:/docker-entrypoint-initdb.d/initialise.sh
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4
network_mode: bridge
environment:
PGADMIN_DEFAULT_EMAIL: xxx
PGADMIN_DEFAULT_PASSWORD: xxx
ports:
- "5050:80"
extra_hosts:
- "host.docker.internal:host-gateway"
Now when I run this locally on my Mac, all is good. I get a database which my node API can reach on localhost, and I get a pgadmin, which can connect to the database by using host.docker.internal.
When I run this on ubuntu linux, however, pgadmin tells me it can't connect to the database. Bear in a mind the non-docker node api can connect to the db just fine on localhost.
I've tried:
- with and without the extra-hosts bit
- on pgadmin trying to connect to the db with 'localhost', '127.0.0.1', 'host.docker.internal', '172.17.0.1' and the public IP
- changing network mode to bridge, host and removing it entirely, all while testing the aforementioned host names.