(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *createOptions, copts *containerOptions)
| 96 | } |
| 97 | |
| 98 | func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *createOptions, copts *containerOptions) error { |
| 99 | if err := validatePullOpt(options.pull); err != nil { |
| 100 | return cli.StatusError{ |
| 101 | Status: withHelp(err, "create").Error(), |
| 102 | StatusCode: 125, |
| 103 | } |
| 104 | } |
| 105 | proxyConfig := dockerCLI.ConfigFile().ParseProxyConfig(dockerCLI.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(copts.env.GetSlice())) |
| 106 | newEnv := make([]string, 0, len(proxyConfig)) |
| 107 | for k, v := range proxyConfig { |
| 108 | if v == nil { |
| 109 | newEnv = append(newEnv, k) |
| 110 | } else { |
| 111 | newEnv = append(newEnv, k+"="+*v) |
| 112 | } |
| 113 | } |
| 114 | copts.env = *opts.NewListOptsRef(&newEnv, nil) |
| 115 | serverInfo, err := dockerCLI.Client().Ping(ctx, client.PingOptions{}) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | containerCfg, err := parse(flags, copts, serverInfo.OSType) |
| 121 | if err != nil { |
| 122 | return cli.StatusError{ |
| 123 | Status: withHelp(err, "create").Error(), |
| 124 | StatusCode: 125, |
| 125 | } |
| 126 | } |
| 127 | id, err := createContainer(ctx, dockerCLI, containerCfg, options) |
| 128 | if err != nil { |
| 129 | return err |
| 130 | } |
| 131 | _, _ = fmt.Fprintln(dockerCLI.Out(), id) |
| 132 | return nil |
| 133 | } |
| 134 | |
| 135 | func pullImage(ctx context.Context, dockerCLI command.Cli, img string, options *createOptions) error { |
| 136 | encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), img) |
searching dependent graphs…