title: Extending postgres image using dockerfile with POSTGRES_PASSWORD
body: <p>I'm extending the postgres image with an argument POSTGRES_PASSWORD=postgres so that my derived container would already have a default password using docker build with dockerfile.</p>
  
  <p>Whenever I ran <code>psql -U postgres</code> on the container from the derived image i made from postgres, I get: </p>
  
  <pre><code>could not connect to server: No such file or directory
          Is the server running locally and accepting
          connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  
  </code></pre>
  
  <p>On my DockerFile I have:</p>
  
  <pre><code>ARG POSTGRES_PASSWORD=postgres
  FROM postgres:alpine
  
  RUN apk add --update nodejs
  RUN apk add --update npm
  RUN apk add --update erlang
  RUN apk add --update elixir
  
  CMD ["/bin/bash"]
  </code></pre>
  
  <p>then I ran</p>
  
  <pre class="lang-sh prettyprint-override"><code>docker build -t myImage .
  docker run --name sample -d -it myImage
  docker exec -it sample bash
  </code></pre>
  
  <p>I want to run <code>psql -U postgres</code> on <code>sample</code> container (image extended from postgres).</p>