title: How to connect to PostgreSQL server that's run on docker
body: <pre><code>mac:camden-market dob$ docker-compose ps
           Name                       Command               State     Ports   
  ---------------------------------------------------------------------------
  camdenmarket_bundle_1    sh                               Exit 0            
  camdenmarket_db_1        /docker-entrypoint.sh postgres   Up       5432/tcp 
  camdenmarket_redis_1     docker-entrypoint.sh redis ...   Up       6379/tcp 
  camdenmarket_solidus_1   ./entrypoint.sh bundle exe ...   Exit 2    
  
  dmac:camden-market dob$ docker ps
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
  b5805a802a8a        postgres            "/docker-entrypoint.s"   17 hours ago        Up 17 hours         5432/tcp            camdenmarket_db_1
  3d4d0bd45e3a        redis               "docker-entrypoint.sh"   19 hours ago        Up 19 hours         6379/tcp            camdenmarket_redis_1
  </code></pre>
  
  <p>I want to connect to postgres db as I did withou docker (psql ...).<br>
  I tried</p>
  
  <pre><code>dmac:camden-market dob$ docker run -d -p 5432:5432 postgres:latest postgresdb
  197402ae06c352ff70651b2888ee5018948e2151886a498c096501ec545249d2
  dmac:camden-market dob$
  </code></pre>
  
  <p>But the outputs is not obvious.   </p>