title: Build postgres docker container with initial schema
body: <p>I'm looking to build dockerfiles that represent company databases that already exist. Similarly, I'd like create a docker file that starts by restoring a psql dump.</p>
  
  <p>I have my <code>psql_dump.sql</code> in the <code>.</code> directory.</p>
  
  <pre><code>FROM postgres
  ADD . /init_data
  run "createdb" "--template=template0" "my_database"
  run  "psql" "-d" "my_database"  --command="create role my_admin superuser"
  run  "psql" "my_database" "&lt;" "init_data/psql_dump.sql"
  </code></pre>
  
  <p>I thought this would be good enough to do it. I'd like to avoid solutions that use a <code>.sh</code> script. Like <a href="https://stackoverflow.com/questions/29600369/starting-a-postgres-container-in-docker-and-then-loading-it-with-data">this solution</a>.</p>
  
  <p>I use template0 since the psql documentation says you need the same users created that were in the original database, and you need to create the database with template0 before you restore.</p>
  
  <p>However, it gives me an error:</p>
  
  <pre><code>createdb: could not connect to database template1: could not connect to server: No such file or directory
          Is the server running locally and accepting
  </code></pre>
  
  <p>I'm also using docker compose for the overall application, if solving this problem in docker-compose is better, I'd be happy to use the base psql image and use docker compose to do this.</p>