I have postgres running in my docker via dockercompose and I have pgadmin running locally on my mac. I can’t get pgadmin to connect to the db. It says password auth failed but I believe the issue is it isn’t connecting on the right host.
I also think this because my sequelize config file is set to use localhost:8410, 8410 being mapped to 5432, and it says ERROR: getaddrinfo ENOTFOUND localhost:8410
I saw this question but now the docker app shows localhost:8410 mapped to 5432. So isn’t that as it should be?
services:
postgres:
image: 'postgres:16'
# By default, a Postgres database is running on the 5432 port.
# If we want to access the database from our computer (outside the container),
# we must share the port with our computer's port.
# The syntax is [port we want on our machine]:[port we want to retrieve in the container]
# Note: You are free to change your computer's port,
# but take into consideration that it will change the way
# you are connecting to your database.
ports:
# Allow postgres to be accessed locally on 8410
- $POSTGRES_LOCAL_PORT:5432
environment:
POSTGRES_USER: ${POSTGRES_USERNAME} # The PostgreSQL user (useful to connect to the database)
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # The PostgreSQL password (useful to connect to the database)
POSTGRES_DB: ${POSTGRES_DB_NAME} # The PostgreSQL default database (automatically created at first launch)
# NOTE: DO NOT ENABLE TRAEFIC FOR THIS CONTAINER, IT SHOULD NOT BE EXPOSED PUBLICLLY
# The `volumes` tag allows us to share a folder with our container
# Its syntax is as follows: [folder path on our machine]:[folder path to retrieve in the container]
volumes:
# In this example, we share the folder `db-data` in our root repository, with the default PostgreSQL data path
# It means that every time the repository is modifying the data inside
# of `/var/lib/postgresql/data/`, automatically the change will appear in `db-data`
# You don't need to create the `db-data` folder. Docker Compose will do it for you
- ./db-data/:/var/lib/postgresql/data/