MCPcopy Create free account
hub / github.com/OpenSN-Library/OpenSN-Library / StopContainer

Function StopContainer

daemon/pkg/module/instance_module.go:161–180  ·  view source on GitHub ↗
(instance *model.Instance)

Source from the content-addressed store, hash-verified

159}
160
161func StopContainer(instance *model.Instance) error {
162
163 containerID := fmt.Sprintf("%s_%s", instance.Type, instance.InstanceID)
164
165 err := utils.DoWithRetry(func() error {
166 _, err := utils.DockerClient.ContainerStop(context.Background(), containerID, client.ContainerStopOptions{})
167 return err
168 }, 4)
169
170 if err != nil {
171 err := fmt.Errorf(
172 "stop container %s error: %s",
173 containerID,
174 err.Error(),
175 )
176 return err
177 }
178
179 return nil
180}
181
182func RemoveContainer(instance *model.Instance) error {
183 containerID := fmt.Sprintf("%s_%s", instance.Type, instance.InstanceID)

Callers 1

UpdateInstanceStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected