MCPcopy Index your code
hub / github.com/docker/cli / runCreate

Function runCreate

cli/command/container/create.go:98–133  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *createOptions, copts *containerOptions)

Source from the content-addressed store, hash-verified

96}
97
98func 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
135func pullImage(ctx context.Context, dockerCLI command.Cli, img string, options *createOptions) error {
136 encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), img)

Callers 2

newCreateCommandFunction · 0.70

Calls 11

validatePullOptFunction · 0.85
withHelpFunction · 0.85
parseFunction · 0.85
createContainerFunction · 0.85
ParseProxyConfigMethod · 0.80
GetSliceMethod · 0.80
ConfigFileMethod · 0.65
ClientMethod · 0.65
OutMethod · 0.65
ErrorMethod · 0.45
PingMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…