title: postgres container doesn't take password from environment variable
body: <p>I'm using a postgres container as part of my microservice application. This is my dockerfile:</p>
  
  <pre><code>FROM postgres:alpine
  COPY *.sh /docker-entrypoint-initdb.d/
  </code></pre>
  
  <p>I can build this image and publish it to my azure image registry. Also I can use this image within my docker stack yml File:</p>
  
  <pre><code>version: '3.4'
  
  services:
      webserver:
          image: myreg.azurecr.io/webserver:latest
          volumes:
              - /etc/letsencrypt:/etc/letsencrypt
              - /var/lib/letsencrypt:/var/lib/letsencrypt
          ports:
              - 80:80
              - 443:443
  
      postgres:
          image: myreg.azurecr.io/postgresql:latest
          environment:
              POSTGRES_PASSWORD: my-super-secure-password
          volumes:
              - /data/postgresql:/var/lib/postgresql
              - /data/postgresql/data:/var/lib/postgresql/data
  
  ....
  </code></pre>
  
  <p>But when I try to connect to this container, I get the following log (from this container)</p>
  
  <pre><code>2018-04-03 10:37:40.836 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
  2018-04-03 10:37:40.836 UTC [1] LOG:  listening on IPv6 address "::", port 5432
  2018-04-03 10:37:40.850 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/
  2018-04-03 10:37:40.936 UTC [17] LOG:  database system was shut down at 2018-04-03 1
  2018-04-03 10:37:40.956 UTC [1] LOG:  database system is ready to accept connections
  2018-04-03 10:37:48.924 UTC [24] FATAL:  password authentication failed for user "postgres"
  2018-04-03 10:37:48.924 UTC [24] DETAIL:  User "postgres" has no password assigned.
  Connection matched pg_hba.conf line 95: "host all all all md5"
  </code></pre>
  
  <p>But when I go into this container with <code>docker exec</code> I can see my password:</p>
  
  <pre><code>$ docker exec -it 7224df929a21 bash
  # printenv
  PG_SHA256=3ccb4e25fe7a7ea6308dea103cac202963e6b746697366d72ec2900449a5e713
  HOSTNAME=7224df929a21
  TERM=xterm
  PG_MAJOR=10
  POSTGRES_PASSWORD=my-super-secure-password
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  PWD=/
  LANG=en_US.utf8
  SHLVL=1
  HOME=/root
  PG_VERSION=10.1
  PGDATA=/var/lib/postgresql/data
  _=/bin/printenv
  </code></pre>
  
  <p>What I'm doing wrong here?</p>