首页 > 解决方案 > 如何在 openshift 中使用正在运行的容器挂载网络共享(SAMBA Windows 共享)

问题描述

我已经尝试使用 cifs 与主机一起安装网络共享,然后托管到 docker 容器。那是有效的。但我想用容器直接挂载。

标签: openshiftmount

解决方案


您可以通过 flexVolume 驱动挂载 cifs,如下所示。

cifs 可以这样使用,参考上面的链接进行 cifs 测试。

apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - name: busybox
    image: busybox
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - name: test
      mountPath: /data
  volumes:
  - name: test
    flexVolume:
      driver: "fstab/cifs"
      fsType: "cifs"
      secretRef:
        name: "cifs-secret"
      options:
        networkPath: "//server/share"
        mountOptions: "dir_mode=0755,file_mode=0644,noperm"

推荐阅读