I'm trying to access PostgreSQL's shell (psql
) using docker-compose
, but I'm having some difficulties... Here's my docker-compose
file:
main:
build: .
volumes:
- .:/code
links:
- postgresdb
environment:
- DEBUG=true
postgresdb:
build: utils/sql/
ports:
- "5432"
environment:
- DEBUG=true
I've tried to access psql
by going through the main
as well as the postgresdb
services, by running
docker-compose run postgresdb psql -h postgresdb -U docker mydatabase
but all I get is psql: could not translate host name "postgresdb" to address: Name or service not known
... which I don't understand because I use postgresdb
as the host in the database configuration file e.g.:
DB_ACCESS = {
'drivername': 'postgres',
# Name of docker-compose service
'host': 'postgresdb',
'port': '5432',
'username': 'docker',
'password': '',
'database': 'mydatabase'
}