title: mysql in docker container can't run through a mounted volume on os x
body: <p>On OS X.</p>
  
  <p>I am trying to run mysql in a docker container through boot2docker, by mounting the volume <code>/var/lib/mysql</code> on the host, so that I can have persistant mysql data.
  I plan to use a data only container in future, but right now I was trying to do this using this option.</p>
  
  <p>I use the following command to run the container :</p>
  
  <p><code>docker run -v /Users/yash/summers/db:/var/lib/mysql -i -t 'image name'</code></p>
  
  <p>The <code>/Users/yash/summers/db</code> folder is already there.</p>
  
  <p>I am facing persmission issues in this. Using commandline, I am able to access the directory, create/remove new files, but when I am running 
  <code>service mysql start</code>, I get the following error:</p>
  
  <pre><code>150528 15:43:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  150528 15:43:43 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
  150528 15:43:43 [Note] /usr/sbin/mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 909 ... 
  150528 15:43:43 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
  150528 15:43:43 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.150528 15:43:43 [Note] Plugin 'FEDERATED' is disabled.
  /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
  150528 15:43:43 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  150528 15:43:43 InnoDB: The InnoDB memory heap is disabled
  150528 15:43:43 InnoDB: Mutexes and rw_locks use GCC atomic builtins
  150528 15:43:43 InnoDB: Compressed tables use zlib 1.2.8 
  150528 15:43:43 InnoDB: Using Linux native AIO
  150528 15:43:43 InnoDB: Initializing buffer pool, size = 128.0M
  150528 15:43:43 InnoDB: Completed initialization of buffer pool
  150528 15:43:43  InnoDB: Operating system error number 13 in a file operation.
  InnoDB: The error means mysqld does not have the access rights to
  InnoDB: the directory.
  InnoDB: File name ./ibdata1
  InnoDB: File operation call: 'create'.
  InnoDB: Cannot continue operation.
  150528 15:43:44 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 
  </code></pre>
  
  <p>I have trying to solve this for the past 2 days, going through so many pages like <a href="https://github.com/jjethwa/icinga2/issues/2" rel="nofollow noreferrer">this</a>, <a href="https://github.com/boot2docker/boot2docker/issues/581" rel="nofollow noreferrer">this</a>, and <a href="https://stackoverflow.com/questions/24212228/boot2docker-on-mac-accessing-local-files">this</a>. </p>
  
  <p>I can't solve my problem. I think I am not able to perfectly do what the solutions are suggesting. </p>
  
  <p>From my understanding, there are some workarounds listed on those pages which include changing the uids and guids, but I think they are not well explained.</p>
  
  <p>Can anybody please explain to me a detailed workaround for this. </p>
  
  <p><strong>Update 1 :</strong> I tried the it with using a data only container also, and still facing the same issue.</p>
  
  <p>I am able to run everything fine if I don't use any <code>-v</code> or <code>--volumes-from</code> option, so I think there is no prob in mysql server.</p>
  
  <p><strong>Update 2 :</strong>
  Dockerfile used for creating the data-only container:</p>
  
  <pre><code>FROM ubuntu
  
  RUN mkdir /var/lib/mysql
  
  VOLUME /var/lib/mysql
  </code></pre>