From 08ed2bc6e8bc49ad988ecd44633620a48fb10967 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 24 Jan 2026 15:33:06 +0100 Subject: [PATCH] cli/command/container: make injecting config.json failures a warning Prior to 1a502e91c937d340ecd3a62de09ae096290160d9, failing to write the container-ID to a file would return an error. After that change, we could end up in a situation where the container was created successfully, but we failed to inject the `config.json`. This failure would be returned as an error, but the container was created (but no ID returned due to the error). This patch changes the error to a warning; while not "ideal" (the container is created, but in a "partial" state), we also shouldn't consider it to be a hard failure; proceed as normal, to allow the user to either use the container as-is, or to delete the container and try again. Alternatively, we could join these errors, but the result will be ambiguous in either case (container created, but an error occurred after the fact). Signed-off-by: Sebastiaan van Stijn --- cli/command/container/create.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cli/command/container/create.go b/cli/command/container/create.go index cc6be07de490..2598323d7e6e 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -363,22 +363,19 @@ func createContainer(ctx context.Context, dockerCLI command.Cli, containerCfg *c } } - for _, w := range response.Warnings { - _, _ = fmt.Fprintln(dockerCLI.Err(), "WARNING:", w) - } - err = containerIDFile.Write(response.ID) - if options.useAPISocket && len(apiSocketCreds) > 0 { // Create a new config file with just the auth. - newConfig := &configfile.ConfigFile{ + if err := copyDockerConfigIntoContainer(ctx, dockerCLI.Client(), response.ID, dockerConfigPathInContainer, &configfile.ConfigFile{ AuthConfigs: apiSocketCreds, - } - - if err := copyDockerConfigIntoContainer(ctx, dockerCLI.Client(), response.ID, dockerConfigPathInContainer, newConfig); err != nil { - return "", fmt.Errorf("injecting docker config.json into container failed: %w", err) + }); err != nil { + response.Warnings = append(response.Warnings, fmt.Sprintf("injecting docker config.json into container failed: %v", err)) } } + for _, w := range response.Warnings { + _, _ = fmt.Fprintln(dockerCLI.Err(), "WARNING:", w) + } + err = containerIDFile.Write(response.ID) return response.ID, err }