Docker 桌面上的 Kubernetes 持久卷 (Windows) [英] Kubernetes persistent volume on Docker Desktop (Windows)
问题描述
我在 Windows 10 上使用 Docker 桌面.出于开发目的,我想将本地文件夹公开给容器.在 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 Pod 规范中的卷类型,用于从主机节点的文件系统挂载文件或目录,其中 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
请查看 this github 问题,以解释 Windows 上 Kubernetes 卷的特殊性.我还假设您已启用 共享驱动器 Docker for Windows 安装中的功能.
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 桌面上的 Kubernetes 持久卷 (Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!