赞
踩
docker-desktop在windows系统中支持容器方案主要采用两种方式
点击Docker Desktop -> Settings->Resources->FILE SHARING,选择你要挂载的分区,点击 Apply&Restart
“文件共享”选项卡仅在Hyper-V模式下可用,因为在WSL 2模式和Windows容器模式下,Windows将自动共享所有文件。

使用示例:
apiVersion: v1 kind: Pod metadata: name: test-local-vol spec: containers: - name: test-local-vol image: library/busybox command: ["/bin/sh"] args: ["-c", "while true; do echo hello >> /root/ccc.log; sleep 10;done"] volumeMounts: - mountPath: /root/ name: local-vol volumes: - name: local-vol hostPath: path: /d/test-data/nginx/html # 要挂载的路径,/d 表示windows下的D盘 type: DirectoryOrCreate
进入wsl模式,查看相关挂载点:
其路径映射关系如下图所示:

测试yaml
apiVersion: v1 kind: Pod metadata: name: test-local-vol spec: containers: - name: test-local-vol image: centos:7 command: ["/bin/sh"] args: ["-c", "while true; do echo hello >> /root/ccc.log; sleep 10;done"] volumeMounts: - mountPath: /root/test/ name: local-vol volumes: - name: local-vol hostPath: path: /run/desktop/mnt/host/d/test # 要挂载的路径,/d 表示windows下的D盘
进入pod验证:

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。