Pass StopOptions to ContainerStop function

Fix #16744

**options** argument in **ContainerStop** [function](https://github.com/moby/moby/blob/master/daemon/stop.go#L23) can't be **nil**
This commit is contained in:
andregri 2023-02-18 19:03:28 +01:00 committed by GitHub
parent a3e3c896d3
commit f87b16b502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -331,6 +331,7 @@ import (
"fmt"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
)
@ -349,7 +350,8 @@ func main() {
for _, container := range containers {
fmt.Print("Stopping container ", container.ID[:10], "... ")
if err := cli.ContainerStop(ctx, container.ID, nil); err != nil {
noWaitTimeout := 0 // to not wait for the container to exit gracefully
if err := cli.ContainerStop(ctx, container.ID, containertypes.StopOptions{Timeout: &noWaitTimeout}); err != nil {
panic(err)
}
fmt.Println("Success")