瀏覽代碼

check secret source exists, as bind mount would create target as a folder otherwise

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 1 年之前
父節點
當前提交
34b18194f7
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      pkg/compose/create.go

+ 7 - 0
pkg/compose/create.go

@@ -1003,11 +1003,18 @@ func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount
 			continue
 		}
 
+		if _, err := os.Stat(definedSecret.File); os.IsNotExist(err) {
+			logrus.Warnf("secret file %s does not exist", definedSecret.Name)
+		}
+
 		mnt, err := buildMount(p, types.ServiceVolumeConfig{
 			Type:     types.VolumeTypeBind,
 			Source:   definedSecret.File,
 			Target:   target,
 			ReadOnly: true,
+			Bind: &types.ServiceVolumeBind{
+				CreateHostPath: false,
+			},
 		})
 		if err != nil {
 			return nil, err