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