title: Docker connection to PostgreSQL failing from host
body: <p>Spent quite sometime on this but no breakthrough. This is my container creation statement:</p>
  
  <pre><code>&gt; docker create --name aasaan_db_dev -e POSTGRES_USER=aasaan -e
  &gt; POSTGRES_PASSWORD=aasaan_admin --expose 5432 postgres:9.4.0
  &gt; 
  &gt; &gt; deepakkt@deepakkt-ubuntu:~$ docker ps
  &gt; 
  &gt; CONTAINER ID        IMAGE               COMMAND                 
  &gt; CREATED             STATUS              PORTS               NAMES
  &gt; 15b21deb19a0        postgres:9.4.0      "/docker-entrypoin..."   About
  &gt; an hour ago   Up About an hour    5432/tcp            aasaan_db_dev
  </code></pre>
  
  <p>The following works:</p>
  
  <pre><code>&gt; deepakkt@deepakkt-ubuntu:~$ docker exec -it aasaan_db_dev psql -U
  &gt; aasaan psql (9.4.0) Type "help" for help.
  &gt; 
  &gt; aasaan=#
  </code></pre>
  
  <p>However, from the host (same error from pgAdmin as well)</p>
  
  <pre><code>&gt; deepakkt@deepakkt-ubuntu:~$ psql -h 127.0.0.1 -U aasaan 
  Password for user aasaan:  
  psql: FATAL:  password authentication failed for user
  &gt; "aasaan" FATAL:  password authentication failed for user "aasaan"
  </code></pre>
  
  <p>Contents of <em>pg_hba.conf</em> inside the container:</p>
  
  <pre><code># TYPE  DATABASE        USER            ADDRESS                 METHOD
  
  # "local" is for Unix domain socket connections only
  local   all             all                                     trust
  # IPv4 local connections:
  host    all             all             127.0.0.1/32            trust
  # IPv6 local connections:
  host    all             all             ::1/128                 trust
  # Allow replication connections from localhost, by a user with the
  # replication privilege.
  #local   replication     postgres                                trust
  #host    replication     postgres        127.0.0.1/32            trust
  #host    replication     postgres        ::1/128                 trust
  
  host all all 0.0.0.0/0 md5
  </code></pre>
  
  <p>What am I missing?</p>