title: How to access Postgres database within docker-compose
body: <p>I'm pretty new to Postgres and Docker, but I am building a webapp with Django that runs inside a docker with a postgresql database. I am trying to view my Postgres database via the command prompt or pgweb. </p>
  
  <p>Unfortunately, I can't seem to find the database at all, I tried using the postgres psql terminal commands, but my database wasn't listed inside. My question is, how is the postgresql database stored within a docker-compose container. Do I need to go into the container manually and then view the database? My ultimate goal is to be able to see a list of all my tables and data within the postgresql database. </p>
  
  <p>Any documents explaining how the postgresql database interacts with a docker-compose would be appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>I just recently added Pgweb, but that doesn't seem to be working</p>
  
  <p><strong>Local.YML</strong></p>
  
  <pre><code>version: '2'
  
  volumes:
    postgres_data_local: {}
    postgres_backup_local: {}
  
  services:
    django:
      build:
        context: .
        dockerfile: ./compose/local/django/Dockerfile
      depends_on:
        - postgres
      volumes:
        - .:/app
      environment:
        - POSTGRES_USER=vicki
        - USE_DOCKER=yes
      ports:
        - "8000:8000"
      command: /start.sh
  
    postgres:
      build:
        context: .
        dockerfile: ./compose/production/postgres/Dockerfile
      volumes:
        - postgres_data_local:/var/lib/postgresql/data
        - postgres_backup_local:/backups
      environment:
        - POSTGRES_USER=vicki
  
    pgweb:
      container_name: pgweb  
      restart: always  
      image: sosedoff/pgweb
      ports:
        - "8081:8081"
      links:
        - postgres:postgres  
      environment:
        - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres
      depends_on:
        - postgres 
  </code></pre>
  
  <p>This is the Postgres Terminal psql I am talking about, When I open my terminal and run:</p>
  
  <pre><code>postgres@dom-Inspiron-7559:~$ psql
  psql (9.3.19)
  Type "help" for help.
  
  postgres=# \l
  postgres=# 
  </code></pre>
  
  <p>This list of databases appears, but I don't believe vickibot is the same as vicki.
  (I had made two apps with django cookiecutter, one within docker and one not in docker. I believe the one I am using right now is "vicki" that is within a docker container, but again i'm not sure and don't know how to tell what database my models file is referencing. I am wondering if I need to somehow enter the docker container to view the database)</p>
  
  <pre><code>                                  List of databases
     Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
  -----------+----------+----------+-------------+-------------+-----------------------
   postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
   template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
             |          |          |             |             | postgres=CTc/postgres
   template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
             |          |          |             |             | postgres=CTc/postgres
   test1     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
   vickibot  | dominic  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  (5 rows)
  </code></pre>