Mount local directory into pod in minikube

前端 未结 8 486
失恋的感觉
失恋的感觉 2020-12-03 02:23

I am running minikube v0.24.1. In this minikube, I will create a Pod for my nginx application. And also I want to pass data from my local directory.

That means I wan

8条回答
  •  庸人自扰
    2020-12-03 02:54

    You can't mount your local directory into your Pod directly.

    First, you need to mount your directory $HOME/go/src/github.com/nginx into your minikube.

    $ minikube start --mount-string="$HOME/go/src/github.com/nginx:/data"
    

    Then If you mount /data into your Pod using hostPath, you will get you local directory data into Pod.

    There is another way

    Host's $HOME directory gets mounted into minikube's /hosthome directory. Here you will get your data

    $ ls -la /hosthome/go/src/github.com/nginx
    

    So to mount this directory, you can change your Pod's hostPath

    hostPath:
      path: /hosthome/go/src/github.com/nginx
    

提交回复
热议问题