title: How do I run a sql file of inserts through docker run?
body: <p>Given a file with a SQL insert:</p>
  <pre><code>INSERT INTO countries (id, country_code, name)
  VALUES
      (1, 'AF', 'Afghanistan'),
      (2, 'AL', 'Albania');
  </code></pre>
  <p>I would like to run the file by using the <code>docker run</code> command on a container that is running postgres.</p>
  <p>I've tried this:</p>
  <pre><code>docker run -e domain=&quot;192.168.99.100&quot; pg /bin/bash -c &quot;psql -d whiteboard_api -a -f inserts_into_countries_table.sql&quot;
  psql: could not connect to server: Connection refused
      Is the server running locally and accepting
      connections on Unix domain socket &quot;/var/run/postgresql/.s.PGSQL.5432&quot;?
  </code></pre>
  <p>you can see my image is pg:</p>
  <pre><code>capistrano:whiteboard_v2 jzollars$ docker ps
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
  6b500bec9210        bbb                 &quot;/usr/bin/supervisord&quot;   4 weeks ago         Up 4 weeks          0.0.0.0:80-&gt;80/tcp       distracted_raman
  c1e88f2695f5        wh                  &quot;/usr/bin/supervisord&quot;   4 weeks ago         Up 4 weeks          0.0.0.0:3000-&gt;3000/tcp   high_einstein
  7e383e99bdc3        pg                  &quot;/usr/lib/postgresql/&quot;   4 weeks ago         Up 4 weeks          0.0.0.0:5432-&gt;5432/tcp   pg_test
  </code></pre>
  <p>How can I load this file and run it in a docker container using <code>docker run</code>?</p>