mirror of https://github.com/docker/docs.git
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:
parent
a3e3c896d3
commit
f87b16b502
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue