title: How to connect to postgres instance running in docker?
body: <p><strong>Update 1</strong>
  Needed to run the following:</p>
  
  <pre><code>root@8809a5d5cf76:/# psql -U x2 -d y2 --password
  </code></pre>
  
  <p>Starting <code>postgres</code> with this <code>docker-compose.yaml</code>:</p>
  
  <pre><code>version: '3.1'
  
  services:
  
    db:
      image: postgres:10.12
      restart: always
      volumes:
        - ~/work/docker/volumes/postgres:/var/lib/postgresql/data
    environment:      
      POSTGRES_USER: x2
      POSTGRES_PASSWORD: password1
      POSTGRES_DB: y2
    ports:
      - 5432:5432
  </code></pre>
  
  <p><code>docker ps</code>:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
  8809a5d5cf76        postgres:10.12      "docker-entrypoint.s…"   5 seconds ago       Up 4 seconds        0.0.0.0:5432-&gt;5432/tcp              thebook_db_1
  </code></pre>
  
  <p>Trying to connect like so:</p>
  
  <pre><code>$ docker exec -it thebook_db_1 bash
  root@8809a5d5cf76:/# psql -U x2
  psql: FATAL:  database "x2" does not exist
  </code></pre>
  
  <p>What is wrong with the <code>POSTGRES_USER</code> in <code>docker-compse</code>?</p>