<p>I'm trying to set up a dev environment with Kubernetes via Minikube. I successfully mounted the same volume to the same data dir on the same image with Docker for Mac, but I'm having trouble with Minikube.</p>

<p>Relevant files and logs:
<code>db-pod.yml</code></p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    name: msyql
  name: db
  namespace: default
spec:
  containers:
    - name: mysqldev
      image: mysql/mysql-server:5.6.32
      ports:
        - containerPort: 3306
          hostPort: 3306
      volumeMounts:
        - mountPath: "/var/lib/mysql"
          name: volumesnew
  volumes:
    - name: volumesnew
      hostPath:
        path: "/Users/eric/Volumes/mysql"
</code></pre>

<p><code>kubectl get pods</code>:</p>

<pre><code>NAME      READY     STATUS    RESTARTS   AGE
db        0/1       Error     1          3s
</code></pre>

<p><code>kubectl logs db</code>:</p>

<pre><code>2016-08-29 20:05:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-29 20:05:55 0 [Note] mysqld (mysqld 5.6.32) starting as process 1 ...
2016-08-29 20:05:55 1 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
</code></pre>

<p><code>kubectl describe pods db</code>:</p>

<pre><code>Name:       db
Namespace:      default
Node:       minikubevm/10.0.2.15
Start Time:     Wed, 31 Aug 2016 07:48:39 -0700
Labels:     name=msyql
Status:     Running
IP:         172.17.0.3
Controllers:    &lt;none&gt;
Containers:
  mysqldev:
    Container ID:       docker://af0937edcd9aa00ebc278bc8be00bc37d60cbaa403c69f71bc1b378182569d3d
    Image:          mysql/mysql-server:5.6.32
    Image ID:       docker://sha256:0fb418d5a10c9632b7ace0f6e7f00ec2b8eb58a451ee77377954fedf6344abc5
    Port:           3306/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:        1
      Started:      Wed, 31 Aug 2016 07:48:42 -0700
      Finished:     Wed, 31 Aug 2016 07:48:43 -0700
    Ready:          False
    Restart Count:      1
    Environment Variables:
      MYSQL_ROOT_PASSWORD:      test
Conditions:
  Type      Status
  Initialized   True
  Ready         False
  PodScheduled  True
Volumes:
  volumesnew:
    Type:       HostPath (bare host directory volume)
    Path:       /Users/eric/Volumes/newmysql
  default-token-il74e:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-il74e
QoS Tier:       BestEffort
Events:
  FirstSeen     LastSeen        Count   From            SubobjectPath           Type        Reason      Message
  ---------     --------        -----   ----            -------------           --------        ------      -------
  7s        7s          1       {default-scheduler }                    Normal      Scheduled       Successfully assigned db to minikubevm
  6s        6s          1       {kubelet minikubevm}    spec.containers{mysqldev}       Normal      Created     Created container with docker id 568f9112dce0
  6s        6s          1       {kubelet minikubevm}    spec.containers{mysqldev}       Normal      Started     Started container with docker id 568f9112dce0
  6s        4s          2       {kubelet minikubevm}    spec.containers{mysqldev}       Normal      Pulled      Container image "mysql/mysql-server:5.6.32" already present on machine
  4s        4s          1       {kubelet minikubevm}    spec.containers{mysqldev}       Normal      Created     Created container with docker id af0937edcd9a
  4s        4s          1       {kubelet minikubevm}    spec.containers{mysqldev}       Normal      Started     Started container with docker id af0937edcd9a
  3s        2s          2       {kubelet minikubevm}    spec.containers{mysqldev}       Warning     BackOff     Back-off restarting failed docker container
  3s        2s          2       {kubelet minikubevm}                    Warning     FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "mysqldev" with CrashLoopBackOff: "Back-off 10s restarting failed container=mysqldev pod=db_default(012d5178-6f8a-11e6-97e8-c2daf2e2520c)"
</code></pre>

<p>I was able to mount the data directory from the host to the container in a test directory, but I'm having trouble mounting to the MySQL data directory. Also, I tried to mount an empty directory to the container's data dir with the appropriate MySQL environment variables set, which in Docker for Mac allowed me to perform a SQL dump in the new dir, but I'm seeing the same errors in Minikube.</p>

<p>Any thought on what might be the cause, or if I'm not setting up my dev environment the preferred Kubernetes/Minikube way, please share your thoughts.</p>

<p>I was able to resolve this with the following:</p>

<pre><code>echo "/Users -network 192.168.99.0 -mask 255.255.255.0 -alldirs -maproot=root:wheel" | sudo tee -a /etc/exports
sudo nfsd restart
minikube start
minikube ssh -- sudo umount /Users
minikube ssh -- sudo /usr/local/etc/init.d/nfs-client start
minikube ssh -- sudo mount 192.168.99.1:/Users /Users -o rw,async,noatime,rsize=32768,wsize=32768,proto=tcp
</code></pre>

<p>I am running Minikube in VirtualBox. I don't know if this will work with other VM drivers - xhyve, etc.</p>

<p>Reference: <a href="https://github.com/kubernetes/minikube/issues/2" rel="nofollow noreferrer">https://github.com/kubernetes/minikube/issues/2</a></p>

<p>EDIT: I should mention that this works for minikube v0.14.0.</p>
