Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config/secret handling: Copy files into containers instead of bind mounting #12448

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
configs and secrets: move the check of read-only service before conta…
…iner creation

Signed-off-by: schaubl <schaubl@users.noreply.github.com>
  • Loading branch information
schaubl committed Feb 18, 2025
commit c835bbc59cfc55cbf7092faff9e34d4d73383b71
8 changes: 8 additions & 0 deletions pkg/compose/create.go
Original file line number Diff line number Diff line change
@@ -990,6 +990,10 @@ func checkContainerConfigs(p types.Project, s types.ServiceConfig) error {
return errors.New("Docker Compose does not support configs.*.template_driver")
}

if s.ReadOnly {
return fmt.Errorf("cannot create config %q in read-only service %q", definedConfig.Name, s.Name)
}

if definedConfig.Environment != "" || definedConfig.Content != "" {
continue
}
@@ -1016,6 +1020,10 @@ func checkContainerSecrets(p types.Project, s types.ServiceConfig) error {
return errors.New("Docker Compose does not support secrets.*.template_driver")
}

if s.ReadOnly {
return fmt.Errorf("cannot create secret %q in read-only service %q", definedSecret.Name, s.Name)
}

if definedSecret.Environment != "" {
continue
}
8 changes: 0 additions & 8 deletions pkg/compose/secrets.go
Original file line number Diff line number Diff line change
@@ -51,10 +51,6 @@ func (s *composeService) injectSecrets(ctx context.Context, project *types.Proje
if content == "" {
continue
}

if service.ReadOnly {
return fmt.Errorf("cannot create secret %q in read-only service %s", file.Name, service.Name)
}

if config.Target == "" {
config.Target = "/run/secrets/" + config.Source
@@ -100,10 +96,6 @@ func (s *composeService) injectConfigs(ctx context.Context, project *types.Proje
continue
}

if service.ReadOnly {
return fmt.Errorf("cannot create config %q in read-only service %s", file.Name, service.Name)
}

if config.Target == "" {
config.Target = "/" + config.Source
}