title: How can I initialize a MySQL database with schema in a Docker container?
body: <p>I am trying to create a container with a MySQL database and add a schema to these database.</p>
  
  <p>My current Dockerfile is:</p>
  
  <pre><code>FROM mysql
  MAINTAINER  (me) &lt;email&gt;
  
  # Copy the database schema to the /data directory
  COPY files/epcis_schema.sql /data/epcis_schema.sql
  
  # Change the working directory
  WORKDIR data
  
  CMD mysql -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE &lt; epcis_schema.sql
  </code></pre>
  
  <p>In order to create the container I am following the documentation provided on Docker and executing this command:</p>
  
  <pre><code>docker run --name ${CONTAINER_NAME} -e MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} -e MYSQL_USER=${DB_USER} -e MYSQL_PASSWORD=${DB_USER_PASSWORD} -e MYSQL_DATABASE=${DB_NAME} -d mvpgomes/epcisdb
  </code></pre>
  
  <p>But when I execute this command the Container is not created and in the Container status it is possible to see that the CMD was not executed successfully, in fact only the <code>mysql</code> command is executed.</p>
  
  <p>Anyway, is there a way to initialize the database with the schema or do I need to perform these operations manually?</p>