我正在尝试将 Windows 中的文件夹连接到容器文件夹。这适用于需要读取文件夹中文件的 .NET 应用程序。在普通的 docker 容器中,使用 docker-compose,该应用程序可以正常运行,但由于这只是我们必须监视的几个不同应用程序之一,因此我们正在尝试让 kubernetes 参与其中。这也是我们失败的地方。作为 kubernetes 的初学者,我使用 kompose.exe 将 compose 文件转换为 kuberetes 风格。但是,无论我使用 hostPath 还是 permanentVolumeClaim 作为标志,我都无法让事情“开箱即用”。使用 hostPath 时,路径非常不正确,而使用 permanentVolumeClaim 时,我收到一条警告,指出不支持在主机上安装卷。因此,我尝试自己完成这一部分,但既不能使用持久卷,也不能直接在部署文件中输入安装数据。我最接近的是我可以进入该文件夹,并且可以更改为其中的子文件夹,但是一旦我尝试运行任何其他命令,无论是“ls”还是“cat”,我都会收到“不允许操作” 。这是我的 docker compose 文件,它按预期工作
version: "3.8"
services:
test-create-hw-file:
container_name: "testcreatehwfile"
image: test-create-hw-file:trygg
network_mode: "host"
volumes:
- /c/temp/testfiles:/app/files
Run Code Online (Sandbox Code Playgroud)
在该文件上运行 konvert compose:
PS C:\temp> .\kompose.exe convert -f .\docker-compose-tchwf.yml --volumes hostPath -v
DEBU Checking validation of provider: kubernetes
DEBU Checking validation of controller:
DEBU Docker Compose version: 3.8
WARN Service "test-create-hw-file" won't be created because 'ports' is …Run Code Online (Sandbox Code Playgroud)