title: psql can not access Postgres running in a Docker container
body: <p>I have successfully built a <a href="https://hub.docker.com/_/postgres/" rel="nofollow noreferrer">postgres</a>-based Docker <a href="https://github.com/pamtrak06/postgis-pgrouting-osm" rel="nofollow noreferrer">image that enables PostGIS</a>:</p>
  
  <p>The I run it:</p>
  
  <pre><code>docker run -d -t -p 5432:5432 -v ./data:/data --name postgis-osm-pgrouting -e POSTGRES_PASSWORD=postgres pamtrak06/postgis-pgrouting-osm bash
  </code></pre>
  
  <p>However, when I try to connect to the database via psql:</p>
  
  <pre><code>psql -h localhost -p 5432 postgres
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code>psql: server closed the connection unexpectedly
          This probably means the server terminated abnormally
          before or while processing the request.
  </code></pre>
  
  <p>I am a beginner with the port forwarding, but it looks like a port-related issue to me.</p>
  
  <p>Any ideas?</p>