Merge pull request #16745 from andregri/patch-1

Pass StopOptions to ContainerStop function
This commit is contained in:
David Karlsson 2023-02-26 20:19:39 +01:00 committed by GitHub
commit 5fb6e210a6
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")