HostPath with minikube - Kubernetes

前端 未结 3 895
刺人心
刺人心 2020-12-05 10:32

UPDATE: I connected to the minikubevm and I see my host directory mounted but there is no files there. Also when I create a file there it will not in my host machine. Any li

3条回答
  •  情书的邮戳
    2020-12-05 11:10

    Best practice would be building the code into your image, you should not run an image with code just coming from the disk. Your Dockerfile should look more like:

    FROM node:latest COPY /code/server.js /code/server.js EXPOSE 8080 CMD /code/server.js

    Then you run the Image on Kubernetes without any volumes. You need to rebuild the image and update the pod every time you update the code.

    Also, I'm currently not aware that minikube allows for mounts between the VM it creates and the host you are running it on.

    If you really want the extreme fast feedback cycle of changing code while the container is running, you might be able to use just Docker by itself with -v /path/to/host/code:/code without Kubernetes and then once you are ready build the image and deploy and test it on minikube. However, I'm not sure that would work if you're changing the main .js file of your node app.

提交回复
热议问题