Add --revive-stopped flag to start stopped containers after an update

This commit is contained in:
Zois Pagoulatos 2019-11-07 10:45:42 +01:00
parent 81540bcb59
commit 8befd82609
No known key found for this signature in database
GPG key ID: A40759B6C8AC2811
4 changed files with 23 additions and 3 deletions

View file

@ -38,7 +38,7 @@ type Client interface {
// * DOCKER_HOST the docker-engine host to send api requests to
// * DOCKER_TLS_VERIFY whether to verify tls certificates
// * DOCKER_API_VERSION the minimum docker api version to work with
func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client {
func NewClient(pullImages bool, includeStopped bool, reviveStopped bool, removeVolumes bool) Client {
cli, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv)
if err != nil {
@ -50,6 +50,7 @@ func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client
pullImages: pullImages,
removeVolumes: removeVolumes,
includeStopped: includeStopped,
reviveStopped: reviveStopped,
}
}
@ -58,6 +59,7 @@ type dockerClient struct {
pullImages bool
removeVolumes bool
includeStopped bool
reviveStopped bool
}
func (client dockerClient) ListContainers(fn t.Filter) ([]Container, error) {
@ -203,7 +205,7 @@ func (client dockerClient) StartContainer(c Container) (string, error) {
}
if !c.IsRunning() {
if !c.IsRunning() && !client.reviveStopped {
return createdContainer.ID, nil
}