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

Function addFlags

cli/command/container/opts.go:149–329  ·  view source on GitHub ↗

addFlags adds all command line flags that will be used by parse to the FlagSet

(flags *pflag.FlagSet)

Source from the content-addressed store, hash-verified

147
148// addFlags adds all command line flags that will be used by parse to the FlagSet
149func addFlags(flags *pflag.FlagSet) *containerOptions {
150 copts := &containerOptions{
151 aliases: opts.NewListOpts(nil),
152 attach: opts.NewListOpts(validateAttach),
153 blkioWeightDevice: opts.NewWeightdeviceOpt(opts.ValidateWeightDevice),
154 capAdd: opts.NewListOpts(nil),
155 capDrop: opts.NewListOpts(nil),
156 dns: opts.NewListOpts(opts.ValidateIPAddress),
157 dnsOptions: opts.NewListOpts(nil),
158 dnsSearch: opts.NewListOpts(opts.ValidateDNSSearch),
159 deviceCgroupRules: opts.NewListOpts(validateDeviceCgroupRule),
160 deviceReadBps: opts.NewThrottledeviceOpt(opts.ValidateThrottleBpsDevice),
161 deviceReadIOps: opts.NewThrottledeviceOpt(opts.ValidateThrottleIOpsDevice),
162 deviceWriteBps: opts.NewThrottledeviceOpt(opts.ValidateThrottleBpsDevice),
163 deviceWriteIOps: opts.NewThrottledeviceOpt(opts.ValidateThrottleIOpsDevice),
164 devices: opts.NewListOpts(nil), // devices can only be validated after we know the server OS
165 env: opts.NewListOpts(opts.ValidateEnv),
166 envFile: opts.NewListOpts(nil),
167 expose: opts.NewListOpts(nil),
168 extraHosts: opts.NewListOpts(opts.ValidateExtraHost),
169 groupAdd: opts.NewListOpts(nil),
170 labels: opts.NewListOpts(opts.ValidateLabel),
171 labelsFile: opts.NewListOpts(nil),
172 linkLocalIPs: opts.NewListOpts(nil),
173 links: opts.NewListOpts(opts.ValidateLink),
174 loggingOpts: opts.NewListOpts(nil),
175 publish: opts.NewListOpts(nil),
176 securityOpt: opts.NewListOpts(nil),
177 storageOpt: opts.NewListOpts(nil),
178 sysctls: opts.NewMapOpts(nil, opts.ValidateSysctl),
179 tmpfs: opts.NewListOpts(nil),
180 ulimits: opts.NewUlimitOpt(nil),
181 volumes: opts.NewListOpts(nil),
182 volumesFrom: opts.NewListOpts(nil),
183 annotations: opts.NewMapOpts(nil, nil),
184 }
185
186 // General purpose flags
187 flags.VarP(&copts.attach, "attach", "a", "Attach to STDIN, STDOUT or STDERR")
188 flags.Var(&copts.deviceCgroupRules, "device-cgroup-rule", "Add a rule to the cgroup allowed devices list")
189 flags.Var(&copts.devices, "device", "Add a host device to the container")
190 flags.Var(&copts.gpus, "gpus", "GPU devices to add to the container ('all' to pass all GPUs)")
191 flags.SetAnnotation("gpus", "version", []string{"1.40"})
192 flags.VarP(&copts.env, "env", "e", "Set environment variables")
193 flags.Var(&copts.envFile, "env-file", "Read in a file of environment variables")
194 flags.StringVar(&copts.entrypoint, "entrypoint", "", "Overwrite the default ENTRYPOINT of the image")
195 flags.Var(&copts.groupAdd, "group-add", "Add additional groups to join")
196 flags.StringVarP(&copts.hostname, "hostname", "h", "", "Container host name")
197 flags.StringVar(&copts.domainname, "domainname", "", "Container NIS domain name")
198 flags.BoolVarP(&copts.stdin, "interactive", "i", false, "Keep STDIN open even if not attached")
199 flags.VarP(&copts.labels, "label", "l", "Set meta data on a container")
200 flags.Var(&copts.labelsFile, "label-file", "Read in a line delimited file of labels")
201 flags.BoolVar(&copts.readonlyRootfs, "read-only", false, "Mount the container's root filesystem as read only")
202 flags.StringVar(&copts.restartPolicy, "restart", string(container.RestartPolicyDisabled), "Restart policy to apply when a container exits")
203 flags.StringVar(&copts.stopSignal, "stop-signal", "", "Signal to stop the container")
204 flags.IntVar(&copts.stopTimeout, "stop-timeout", 0, "Timeout (in seconds) to stop a container")
205 flags.SetAnnotation("stop-timeout", "version", []string{"1.25"})
206 flags.Var(copts.sysctls, "sysctl", "Sysctl options")

Callers 3

setupRunFlagsFunction · 0.85
newRunCommandFunction · 0.85
newCreateCommandFunction · 0.85

Calls

no outgoing calls

Tested by 1

setupRunFlagsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…