mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Support for --cleanup flag
The --cleanup flag will cause watchtower to automatically remove the old image after a container is restart with a new image.
This commit is contained in:
parent
b8ba80df2d
commit
dd80aa4a0d
10 changed files with 117 additions and 7 deletions
|
@ -21,6 +21,7 @@ type Client interface {
|
|||
StartContainer(Container) error
|
||||
RenameContainer(Container, string) error
|
||||
IsContainerStale(Container) (bool, error)
|
||||
RemoveImage(Container) error
|
||||
}
|
||||
|
||||
func NewClient(dockerHost string, tlsConfig *tls.Config, pullImages bool) Client {
|
||||
|
@ -147,6 +148,13 @@ func (client DockerClient) IsContainerStale(c Container) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
func (client DockerClient) RemoveImage(c Container) error {
|
||||
imageID := c.ImageID()
|
||||
log.Infof("Removing image %s", imageID)
|
||||
_, err := client.api.RemoveImage(imageID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (client DockerClient) waitForStop(c Container, waitTime time.Duration) error {
|
||||
timeout := time.After(waitTime)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue