title: MySQL Docker container is not saving data to new image
body: <p>I'm trying to create a MySQL Docker container that is preset with a certain schema and seed data so that I can have other containers connect to it as a db. I'm using the <a href="https://registry.hub.docker.com/u/dockerfile/mysql/" rel="noreferrer">trusted dockerfile/mysql image</a> as a base, and I wrote a Dockerfile to create a new image from that base and add my schema.sql into it. After building that image (mysql:base), I've been trying to run bash in new container, then go into mysql and create my database and then import the schema. I then exit the container and try to commit the container to a new Docker image.  However, the resulting image does not persist any of the changes I made to the MySQL db. It does persist other files that I wrote in the container, but not the db.</p>
  
  <p>Here is the Dockerfile I use to build the initial image (myorg/mysql:base).</p>
  
  <pre><code>FROM dockerfile/mysql:latest
  MAINTAINER (me)
  
  ADD schema.sql /data/schema.sql
  
  EXPOSE 3306
  
  # Define working directory.
  WORKDIR /data
  
  CMD ["mysqld_safe"]
  </code></pre>
  
  <p>After building that, I go into the image:</p>
  
  <pre><code>docker run -i -t myorg/mysql:base bash
  </code></pre>
  
  <p>And run MySQL to import the schema:</p>
  
  <pre><code>myslqd_safe &amp;
  141218 00:15:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  
  mysql -u root
  
  mysql&gt; CREATE DATABASE mydb;
  exit;
  
  mysql -u root -D mydb &lt; schema.sql
  </code></pre>
  
  <p>I can go into mysql and verify the schema has been imported successfully:</p>
  
  <pre><code> mysql -u root -D mydb -e "SELECT * from tokens;"
  </code></pre>
  
  <p>Also, if I go into <code>/var/lib/mysql</code> I can see that there is a <code>mydb</code> directory that contains .frm files corresponding to the db.</p>
  
  <p>But when I exit and try to commit that container to a new image:</p>
  
  <pre><code>docker commit -m="import schema.sql" -a="Me" 72c2ff39dd65 myorg/mysql:seed
  </code></pre>
  
  <p>And then go into the new image:</p>
  
  <pre><code>docker run -i -t --rm myorg/mysql:seed bash
  </code></pre>
  
  <p>The db files are no longer in /var/lib/mysql, and running <code>mysql -u root -e "SHOW DATABASES"</code> does not show the <code>mydb</code> database, only the default <code>mysql</code>, <code>information_schema</code>, and <code>performance_schema</code> dbs. I found that if I created a new textfile in the container (<code>echo 'test' &gt; newfile</code>), that file would be present in the committed image, but not the db.</p>
  
  <p>I wonder if this has something to do with the fact that the trusted image Dockerfile has <code>VOLUME ["/etc/mysql", "/var/lib/mysql"]</code> so it mounts the db directory as a volume. My Dockerfile does not have this command, but I don't know if it's inherited anyway (I don't really understand how volumes work well enough to know how this might affect my build). I don't need the db mounted as a volume because I need another container to connect to it over a network connection (I'm going to use docker links for that).</p>
  
  <p>FWIW, I am running boot2docker 1.3.2 on OS X 10.9.5.</p>