From 34b18194f7e9efa1ac8c0e67c554c46b61bf5690 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 23 Sep 2024 09:48:07 +0200 Subject: [PATCH] check secret source exists, as bind mount would create target as a folder otherwise Signed-off-by: Nicolas De Loof --- pkg/compose/create.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index c4d1734fa..f4178d6af 100644 --- a/pkg/compose/create.go +++ b/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