Docker桌面(Windows)上的Kubernetes持久卷 [英] Kubernetes persistent volume on Docker Desktop (Windows)
问题描述
我正在Windows 10上使用Docker Desktop.出于开发目的,我想向容器公开本地文件夹.在Docker中运行容器时,我可以通过指定音量标志(-v)来实现.
I'm using Docker Desktop on Windows 10. For the purposes of development, I want to expose a local folder to a container. When running the container in Docker, I do this by specifying the volume flag (-v).
在Kubernetes中运行容器时如何实现相同的目的?
How do I achieve the same when running the container in Kubernetes?
推荐答案
您应使用 hostpath 主机规范中的卷类型,用于从主机节点的文件系统中挂载文件或目录,其中hostPath.path字段应采用以下格式,以接受Windows之类的路径:
You should use hostpath Volume type in your pod`s spec to mount a file or directory from the host node’s filesystem, where hostPath.path field should be of following format to accept Windows like paths:
- /W/fooapp/influxdb
- //W/fooapp/influxdb
- /////W/fooapp/influxdb
请检查此 github问题,以解释Windows上Kubernetes Volumes的特殊性. 我还假设您已启用共享驱动器" 功能.
Please check this github issue explaining peculiarities of Kubernetes Volumes on Windows. I assume also that you have enabled Shared Drives feature in your Docker for Windows installation.
这篇关于Docker桌面(Windows)上的Kubernetes持久卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!