title: Schema created in Docker by postgres user does not exist
body: <p>I am building a Docker container for my PostgresSQL 9.4.5 database and I'd like to create the table structures when the container starts.  In the script included in my <code>/docker-entrypoint-initdb.d/</code> directory is this series of commands:</p>
  
  <pre><code>#!/usr/bin/env bash
  
  export PGUSER=postgres
  echo "***CREATING DATABASE, USERS, AND ROLES***"
  psql &lt;&lt;-EOSQL
      CREATE USER vpager WITH PASSWORD '&lt;pass&gt;';
      CREATE DATABASE vpager;
      GRANT ALL PRIVILEGES ON DATABASE vpager TO vpager;
      REVOKE ALL ON DATABASE vpager FROM PUBLIC;
      CREATE ROLE standarduser;
      CREATE USER vpageruser WITH PASSWORD '&lt;pass&gt;';
      \connect vpager
      CREATE SCHEMA ticketing;
      GRANT ALL PRIVILEGES ON SCHEMA ticketing TO vpager;
      GRANT CONNECT ON DATABASE vpager TO standarduser;
      GRANT SELECT, UPDATE, INSERT, DELETE ON ALL TABLES IN SCHEMA ticketing TO standarduser;
      GRANT standarduser TO vpageruser;
  EOSQL
  
  echo "***CREATING TABLE STRUCTURES***"
  psql -U vpager vpager &lt; /docker-entrypoint-initdb.d/create-vpager-tables.sql
  </code></pre>
  
  <p>The SQL script:</p>
  
  <pre><code>CREATE TABLE ticketing.merchant
  (
    merchant_id SERIAL PRIMARY KEY,
    now_serving INT
  );
  
  CREATE TABLE ticketing.ticket
  (
    ticket_id SERIAL,
    merchant_id INT REFERENCES ticketing.merchant(merchant_id),
    create_ts TIMESTAMP,
    PRIMARY KEY (ticket_id, merchant_id)
  );
  </code></pre>
  
  <p>As you can see, the idea is to create a non-privileged user for doing CRUD operations.  The problem is that when the <code>create-vpager-tables.sql</code> command runs, it can't see the schema that postgres created:</p>
  
  <pre><code>ERROR:  schema "ticketing" does not exist
  STATEMENT:  CREATE TABLE ticketing.merchant
          (
            merchant_id SERIAL PRIMARY KEY,
            now_serving INT
          );
  ERROR:  schema "ticketing" does not exist
  ERROR:  schema "ticketing" does not exist
  </code></pre>
  
  <p>Yet, if I add a <code>CREATE SCHEMA</code> statement to the top of <code>create-vpager-tables.sql</code>, it says it already exists:</p>
  
  <pre><code>ERROR:  schema "ticketing" already exists
  </code></pre>
  
  <p>How do I resolve these errors?  I tried setting my search path at the top of the SQL file, but the same thing happened; it's like a "Schrodinger" schema.  </p>