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 }