@@ -211,7 +211,7 @@ func newCIDFile(cidPath string) (*cidFile, error) {
211211}
212212
213213//nolint:gocyclo
214- func createContainer (ctx context.Context , dockerCLI command.Cli , containerCfg * containerConfig , options * createOptions ) (containerID string , err error ) {
214+ func createContainer (ctx context.Context , dockerCLI command.Cli , containerCfg * containerConfig , options * createOptions ) (containerID string , _ error ) {
215215 config := containerCfg .Config
216216 hostConfig := containerCfg .HostConfig
217217 networkingConfig := containerCfg .NetworkingConfig
@@ -220,8 +220,7 @@ func createContainer(ctx context.Context, dockerCLI command.Cli, containerCfg *c
220220
221221 // TODO(thaJeztah): add a platform option-type / flag-type.
222222 if options .platform != "" {
223- _ , err = platforms .Parse (options .platform )
224- if err != nil {
223+ if _ , err := platforms .Parse (options .platform ); err != nil {
225224 return "" , err
226225 }
227226 }
@@ -247,8 +246,9 @@ func createContainer(ctx context.Context, dockerCLI command.Cli, containerCfg *c
247246
248247 if options .useAPISocket {
249248 // We'll create two new mounts to handle this flag:
249+ //
250250 // 1. Mount the actual docker socket.
251- // 2. A synthezised ~/.docker/config.json with resolved tokens.
251+ // 2. A synthesized ~/.docker/config.json with resolved tokens.
252252
253253 if dockerCLI .ServerInfo ().OSType == "windows" {
254254 return "" , errors .New ("flag --use-api-socket can't be used with a Windows Docker Engine" )
@@ -363,24 +363,23 @@ func createContainer(ctx context.Context, dockerCLI command.Cli, containerCfg *c
363363 }
364364 }
365365
366- containerID = response .ID
367366 for _ , w := range response .Warnings {
368367 _ , _ = fmt .Fprintln (dockerCLI .Err (), "WARNING:" , w )
369368 }
370- err = containerIDFile .Write (containerID )
369+ err = containerIDFile .Write (response . ID )
371370
372371 if options .useAPISocket && len (apiSocketCreds ) > 0 {
373372 // Create a new config file with just the auth.
374373 newConfig := & configfile.ConfigFile {
375374 AuthConfigs : apiSocketCreds ,
376375 }
377376
378- if err := copyDockerConfigIntoContainer (ctx , dockerCLI .Client (), containerID , dockerConfigPathInContainer , newConfig ); err != nil {
377+ if err := copyDockerConfigIntoContainer (ctx , dockerCLI .Client (), response . ID , dockerConfigPathInContainer , newConfig ); err != nil {
379378 return "" , fmt .Errorf ("injecting docker config.json into container failed: %w" , err )
380379 }
381380 }
382381
383- return containerID , err
382+ return response . ID , err
384383}
385384
386385func validatePullOpt (val string ) error {
0 commit comments