mirror of https://github.com/docker/docs.git
Merge pull request #16745 from andregri/patch-1
Pass StopOptions to ContainerStop function
This commit is contained in:
commit
5fb6e210a6
|
@ -331,6 +331,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -349,7 +350,8 @@ func main() {
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
fmt.Print("Stopping container ", container.ID[:10], "... ")
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println("Success")
|
fmt.Println("Success")
|
||||||
|
|
Loading…
Reference in New Issue