11package daemon // import "github.com/docker/docker/daemon"
22
33import (
4+ "context"
45 "fmt"
56
67 containertypes "github.com/docker/docker/api/types/container"
@@ -14,12 +15,12 @@ import (
1415// timeout, ContainerRestart will wait forever until a graceful
1516// stop. Returns an error if the container cannot be found, or if
1617// there is an underlying error at any stage of the restart.
17- func (daemon * Daemon ) ContainerRestart (name string , seconds * int ) error {
18+ func (daemon * Daemon ) ContainerRestart (ctx context. Context , name string , options containertypes. StopOptions ) error {
1819 ctr , err := daemon .GetContainer (name )
1920 if err != nil {
2021 return err
2122 }
22- err = daemon .containerRestart (ctr , seconds )
23+ err = daemon .containerRestart (ctx , ctr , options )
2324 if err != nil {
2425 return fmt .Errorf ("Cannot restart container %s: %v" , name , err )
2526 }
@@ -31,7 +32,7 @@ func (daemon *Daemon) ContainerRestart(name string, seconds *int) error {
3132// container. When stopping, wait for the given duration in seconds to
3233// gracefully stop, before forcefully terminating the container. If
3334// given a negative duration, wait forever for a graceful stop.
34- func (daemon * Daemon ) containerRestart (container * container.Container , seconds * int ) error {
35+ func (daemon * Daemon ) containerRestart (ctx context. Context , container * container.Container , options containertypes. StopOptions ) error {
3536 // Determine isolation. If not specified in the hostconfig, use daemon default.
3637 actualIsolation := container .HostConfig .Isolation
3738 if containertypes .Isolation .IsDefault (actualIsolation ) {
@@ -56,7 +57,7 @@ func (daemon *Daemon) containerRestart(container *container.Container, seconds *
5657 autoRemove := container .HostConfig .AutoRemove
5758
5859 container .HostConfig .AutoRemove = false
59- err := daemon .containerStop (container , seconds )
60+ err := daemon .containerStop (ctx , container , options )
6061 // restore AutoRemove irrespective of whether the stop worked or not
6162 container .HostConfig .AutoRemove = autoRemove
6263 // containerStop will write HostConfig to disk, we shall restore AutoRemove
0 commit comments