MCPcopy Create free account
hub / github.com/docker/cli / runUpdate

Function runUpdate

cli/command/container/update.go:91–147  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, options *updateOptions)

Source from the content-addressed store, hash-verified

89}
90
91func runUpdate(ctx context.Context, dockerCli command.Cli, options *updateOptions) error {
92 var err error
93
94 if options.nFlag == 0 {
95 return errors.New("you must provide one or more flags when using this command")
96 }
97
98 var restartPolicy containertypes.RestartPolicy
99 if options.restartPolicy != "" {
100 restartPolicy, err = opts.ParseRestartPolicy(options.restartPolicy)
101 if err != nil {
102 return err
103 }
104 }
105
106 var pidsLimit *int64
107 if options.pidsLimit != 0 {
108 pidsLimit = &options.pidsLimit
109 }
110
111 updateConfig := client.ContainerUpdateOptions{
112 Resources: &containertypes.Resources{
113 BlkioWeight: options.blkioWeight,
114 CpusetCpus: options.cpusetCpus,
115 CpusetMems: options.cpusetMems,
116 CPUShares: options.cpuShares,
117 Memory: options.memory.Value(),
118 MemoryReservation: options.memoryReservation.Value(),
119 MemorySwap: options.memorySwap.Value(),
120 CPUPeriod: options.cpuPeriod,
121 CPUQuota: options.cpuQuota,
122 CPURealtimePeriod: options.cpuRealtimePeriod,
123 CPURealtimeRuntime: options.cpuRealtimeRuntime,
124 NanoCPUs: options.cpus.Value(),
125 PidsLimit: pidsLimit,
126 },
127 RestartPolicy: &restartPolicy,
128 }
129
130 var (
131 warns []string
132 errs []error
133 )
134 for _, ctr := range options.containers {
135 r, err := dockerCli.Client().ContainerUpdate(ctx, ctr, updateConfig)
136 if err != nil {
137 errs = append(errs, err)
138 } else {
139 _, _ = fmt.Fprintln(dockerCli.Out(), ctr)
140 }
141 warns = append(warns, r.Warnings...)
142 }
143 if len(warns) > 0 {
144 _, _ = fmt.Fprintln(dockerCli.Out(), strings.Join(warns, "\n"))
145 }
146 return errors.Join(errs...)
147}

Callers 1

newUpdateCommandFunction · 0.70

Calls 3

ValueMethod · 0.65
ClientMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…