From f87b16b502c4b00ccc8c02f5a581818f33ce94f8 Mon Sep 17 00:00:00 2001 From: andregri Date: Sat, 18 Feb 2023 19:03:28 +0100 Subject: [PATCH] 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** --- engine/api/sdk/examples.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/api/sdk/examples.md b/engine/api/sdk/examples.md index 8cbc4f69b8..664d0fa194 100644 --- a/engine/api/sdk/examples.md +++ b/engine/api/sdk/examples.md @@ -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")