title: PostgreSQL docker image build errors
body: <p>I am creating a docker image for postgresql installation from sources. Here is my Dockerfile which I created according to the <a href="https://www.postgresql.org/docs/9.6/static/install-short.html" rel="nofollow noreferrer">postgresql documentation</a>:</p>
  
  <pre><code>FROM ubuntu
  
  RUN apt-get update &amp;&amp; apt-get install gcc zlib1g-dev libreadline6-dev apt-utils make -y
  
  RUN mkdir -p /tmp/downloads
  
  ADD https://ftp.postgresql.org/pub/source/v9.6.6/postgresql-9.6.6.tar.gz /tmp/downloads
  
  RUN cd /tmp/downloads &amp;&amp; tar -zxf postgresql-9.6.6.tar.gz
  
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; make configure
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; ./configure
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; make
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; su
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; make install
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; adduser postgres
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; mkdir /usr/local/pgsql/data
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; chown postgres /usr/local/pgsql/data
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; su postgres
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; /usr/local/pgsql/bin/createdb test
  RUN cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; /usr/local/pgsql/bin/psql test
  </code></pre>
  
  <p>So when I run <code>docker build -t roksolanad/psql:latest .</code> I get errors:</p>
  
  <pre><code>initdb: cannot be run as root
  Please log in (using, e.g., "su") as the (unprivileged) user that will
  own the server process.
  The command '/bin/sh -c cd /tmp/downloads/postgresql-9.6.6 &amp;&amp; /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data' returned a non-zero code: 1
  </code></pre>
  
  <p>So how can I fix my Dockerfile? I would be very grateful for some help!</p>