title: Executing SQL scripts on docker container
body: <p>I have a docker container running mysql and I want to push a .sql file to the container and then have mysql execute the commands in it.  The first step is fairly straightforward:</p>
  
  <pre><code>docker cp ./dummy.sql &lt;container_id&gt;:/
  </code></pre>
  
  <p>From there I am trying to run mysql from the command line and point it to the file that I just pushed to the container.</p>
  
  <pre><code>docker exec &lt;container_id&gt; mysql -u root -ppassword &lt; /dummy.sql
  </code></pre>
  
  <p>This command appears to be trying to use /sample.sql as stdin locally rather than on the container.  I also tried wrapping quotes around everything after the container ID which also seems to not work.</p>
  
  <p>I also tried pushing a .sh file with the command in it to the docker container and then just executing that, but that is less ideal and also not working.  Any advice?</p>