title: docker postgresql: How come the public schema owner is not postgres of the new database created if i specify POSTGRES_USER="testing"
body: <p>I have the following configuration in the docker-compose file</p>
  
  <pre><code>  postgresql:
      image: "postgres:11-alpine"
      volumes:
        - type: bind
          source: ./postgresql
          target: /var/lib/postgresql/data
      environment:
        POSTGRES_USER: 'testing'
        POSTGRES_PASSWORD: 'testing'
        POSTGRES_DB: 'testing'
        PGDATA: '/var/lib/postgresql/data/pgdata'
  </code></pre>
  
  <p>When i run docker-compose i found that there is a role called <code>testing</code> and a database called <code>testing</code></p>
  
  <p>The database <code>testing</code> has a <code>schema</code> called <code>public</code>.</p>
  
  <p>I see the <code>owner</code> of the <code>public</code> is <code>testing</code></p>
  
  <p>How is this possible. Generally when we create a new database the <code>template1</code> is copied. So the owner of the schema <code>public</code> should be <code>postgres</code></p>
  
  <p>If it is set by the Dockerfile then how it is done. I want to know which command does this.</p>
  
  <p>I checked the <code>docker-entrypoint.sh</code> <a href="https://github.com/docker-library/postgres/blob/33bccfcaddd0679f55ee1028c012d26cd196537d/11/alpine/docker-entrypoint.sh" rel="nofollow noreferrer">https://github.com/docker-library/postgres/blob/33bccfcaddd0679f55ee1028c012d26cd196537d/11/alpine/docker-entrypoint.sh</a></p>
  
  <p>I found one command used to create the user.
  the command is</p>
  
  <pre><code>eval 'initdb --username="$POSTGRES_USER" --pwfile=&lt;(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'
  </code></pre>
  
  <p>How can we use <code>initdb</code> to create user. Generally we <code>CREATE ROLE</code> sql or <code>createuser</code> command</p>
  
  <p>If possible how exactly this is achieving the <code>public</code> owner changed to <code>testing</code></p>
  
  <p>ALSO i found the <code>public</code> schema owner for database name <code>postgres</code> is also <code>testing</code>.</p>