mirror of
https://github.com/docker/docs.git
synced 2026-03-27 14:28:47 +07:00
Merge pull request #16745 from andregri/patch-1
Pass StopOptions to ContainerStop function
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user