title: How to make Postgres (Docker) accessible for any IP remotely?
body: <p>I'm creating a PostgreSQL container using the following command:</p>
  
  <pre><code>docker run -p 5432:5432 -e POSTGRES_PASSWORD=123456789 -d postgres:9.3.6
  </code></pre>
  
  <p>which will download the required base image, and create a container.</p>
  
  <p>When I check the service connectivity using telnet I get:</p>
  
  <pre><code>$ telnet 127.0.0.1 5432
  
  Trying 127.0.0.1...
  Connected to 127.0.0.1.
  Escape character is '^]'.
  </code></pre>
  
  <p>It works properly using <code>127.0.0.1</code> as the IP address, but if I use my computer's IP address, the console gets stuck and after a long while it gives me a timeout error.</p>
  
  <pre><code>$ telnet 191.115.52.110 5432
  
  Trying 191.115.52.110...
  telnet: Unable to connect to remote host: Connection timed out
  </code></pre>
  
  <p>What should I do in order to have my PostgreSQL container accessible from any IP?</p>
  
  <p>I have tried passing a config attribute like this. However when I do, the container exits immediately (perhaps it crashes).</p>
  
  <pre><code>docker run -p 5432:5432 -e POSTGRES_PASSWORD=123456789 -d postgres:9.3.6 -c "listen_addresses = '*'"
  </code></pre>
  
  <p>When I execute <code>show listen_addresses</code> to get the listen_addresses runtime attribute, I get <code>*</code> which means the parameter was set to <code>*</code> correctly, but still it doesn't work.</p>
  
  <pre><code>postgres=# show listen_addresses;
   listen_addresses 
  ------------------
   *
  (1 row)
  </code></pre>