With regular native Docker on Mac, without minikube, I can take the official example from https://docs.docker.com/engine/admin/volumes/volumes/#start-a-container-with-a-volume
run:
docker run -d \
-it \
--name devtest \
--mount source=myvol2,target=/app \
nginx:latest
Then I can run docker inspect devtest
and see that the mount was created:
"Mounts": [
{
"Type": "volume",
"Name": "myvol2",
"Source": "/var/lib/docker/volumes/myvol2/_data",
"Destination": "/app",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
I can run docker volume ls
and see myvol2
If I am using the latest minikube, currently v0.22.3, with a fresh minikube local VM:
minikube delete
rm -rf ~/.kube
rm -rf ~/.minikube
minikube start
Starting local Kubernetes v1.7.5 cluster...
Then use the minikube VM version of Docker with eval $(minikube docker-env)
, then repeat the same command from earlier:
docker run -d \
-it \
--name devtest \
--mount source=myvol2,target=/app \
nginx:latest
Then docker inspect devtest
comes back with an empty mounts section: "Mounts": []
. and docker volume ls
shows no myvol2
. In other words, the Docker volumes seem to simply not work with minikube.
FYI, here is the output of docker version
when working with Minikube v0.22.3:
Client:
Version: 17.06.2-ce
API version: 1.23
Go version: go1.8.3
Git commit: cec0b72
Built: Tue Sep 5 20:12:06 2017
OS/Arch: darwin/amd64
Server:
Version: 1.12.6
API version: 1.24 (minimum version )
Go version: go1.6.4
Git commit: 78d1802
Built: Wed Jan 11 00:23:16 2017
OS/Arch: linux/amd64
Experimental: false
https://github.com/kubernetes/minikube/issues/3001#issuecomment-446055883 may be the answer. Volume should be in minikube env in this case. As they mention in the link above:
So you have to mount your folder(host) into minikube(vm) first (use
minikube mount
), so the docker can access it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With