mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
commit
940e25acb6
12 changed files with 99 additions and 26 deletions
|
@ -375,6 +375,24 @@
|
||||||
"contributions": [
|
"contributions": [
|
||||||
"code"
|
"code"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "8ear",
|
||||||
|
"name": "Max H.",
|
||||||
|
"avatar_url": "https://avatars0.githubusercontent.com/u/10329648?v=4",
|
||||||
|
"profile": "https://github.com/8ear",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "pjknkda",
|
||||||
|
"name": "Jungkook Park",
|
||||||
|
"avatar_url": "https://avatars0.githubusercontent.com/u/4986524?v=4",
|
||||||
|
"profile": "https://pjknkda.github.io",
|
||||||
|
"contributions": [
|
||||||
|
"doc"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
|
11
.github/config.yml
vendored
11
.github/config.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
newIssueWelcomeComment: >
|
|
||||||
Hi there!
|
|
||||||
|
|
||||||
Thanks a bunch for opening your first issue! :pray:
|
|
||||||
As you're new to this repo, we'd like to suggest that you read our [code of conduct](https://github.com/containrrr/watchtower/blob/master/CODE_OF_CONDUCT.md)
|
|
||||||
|
|
||||||
newPRWelcomeComment: >
|
|
||||||
Thanks for opening this pull request! Please check out our [contributing guidelines](https://github.com/containrrr/watchtower/blob/master/CONTRIBUTING.md) as well as our [code of conduct](https://github.com/containrrr/watchtower/blob/master/CODE_OF_CONDUCT.md).
|
|
||||||
|
|
||||||
firstPRMergeComment: >
|
|
||||||
Congrats on merging your first pull request! We are all very proud of you! :sparkles:
|
|
18
.github/workflows/greetings.yml
vendored
Normal file
18
.github/workflows/greetings.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
name: Greetings
|
||||||
|
|
||||||
|
on: [pull_request, issues]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
greeting:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/first-interaction@v1
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-message: >
|
||||||
|
Hi there! 👋🏼
|
||||||
|
As you're new to this repo, we'd like to suggest that you read our [code of conduct](https://github.com/containrrr/watchtower/blob/master/CODE_OF_CONDUCT.md)
|
||||||
|
as well as our [contribution guidelines](https://github.com/containrrr/watchtower/blob/master/CONTRIBUTING.md).
|
||||||
|
Thanks a bunch for opening your first issue! 🙏
|
||||||
|
pr-message: >
|
||||||
|
Congratulations on opening your first pull request! We'll get back to you as soon as possible. In the meantime, please make sure you've updated the documentation to reflect your changes and have added test automation as needed. Thanks! 🙏🏼
|
|
@ -115,6 +115,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||||
<td align="center"><a href="http://kaloyan.raev.name"><img src="https://avatars2.githubusercontent.com/u/468091?v=4" width="100px;" alt="Kaloyan Raev"/><br /><sub><b>Kaloyan Raev</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=kaloyan-raev" title="Code">💻</a> <a href="https://github.com/containrrr/watchtower/commits?author=kaloyan-raev" title="Tests">⚠️</a></td>
|
<td align="center"><a href="http://kaloyan.raev.name"><img src="https://avatars2.githubusercontent.com/u/468091?v=4" width="100px;" alt="Kaloyan Raev"/><br /><sub><b>Kaloyan Raev</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=kaloyan-raev" title="Code">💻</a> <a href="https://github.com/containrrr/watchtower/commits?author=kaloyan-raev" title="Tests">⚠️</a></td>
|
||||||
<td align="center"><a href="https://github.com/sixth"><img src="https://avatars3.githubusercontent.com/u/11591445?v=4" width="100px;" alt="sixth"/><br /><sub><b>sixth</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=sixth" title="Documentation">📖</a></td>
|
<td align="center"><a href="https://github.com/sixth"><img src="https://avatars3.githubusercontent.com/u/11591445?v=4" width="100px;" alt="sixth"/><br /><sub><b>sixth</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=sixth" title="Documentation">📖</a></td>
|
||||||
<td align="center"><a href="https://foosel.net"><img src="https://avatars0.githubusercontent.com/u/83657?v=4" width="100px;" alt="Gina Häußge"/><br /><sub><b>Gina Häußge</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=foosel" title="Code">💻</a></td>
|
<td align="center"><a href="https://foosel.net"><img src="https://avatars0.githubusercontent.com/u/83657?v=4" width="100px;" alt="Gina Häußge"/><br /><sub><b>Gina Häußge</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=foosel" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://github.com/8ear"><img src="https://avatars0.githubusercontent.com/u/10329648?v=4" width="100px;" alt="Max H."/><br /><sub><b>Max H.</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=8ear" title="Code">💻</a></td>
|
||||||
|
<td align="center"><a href="https://pjknkda.github.io"><img src="https://avatars0.githubusercontent.com/u/4986524?v=4" width="100px;" alt="Jungkook Park"/><br /><sub><b>Jungkook Park</b></sub></a><br /><a href="https://github.com/containrrr/watchtower/commits?author=pjknkda" title="Documentation">📖</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,13 @@ func PreRun(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
noPull, _ := f.GetBool("no-pull")
|
noPull, _ := f.GetBool("no-pull")
|
||||||
includeStopped, _ := f.GetBool("include-stopped")
|
includeStopped, _ := f.GetBool("include-stopped")
|
||||||
|
reviveStopped, _ := f.GetBool("revive-stopped")
|
||||||
removeVolumes, _ := f.GetBool("remove-volumes")
|
removeVolumes, _ := f.GetBool("remove-volumes")
|
||||||
|
|
||||||
client = container.NewClient(
|
client = container.NewClient(
|
||||||
!noPull,
|
!noPull,
|
||||||
includeStopped,
|
includeStopped,
|
||||||
|
reviveStopped,
|
||||||
removeVolumes,
|
removeVolumes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ Enable debug mode with verbose logging.
|
||||||
|
|
||||||
```
|
```
|
||||||
Argument: --debug
|
Argument: --debug
|
||||||
Environment Variable: N/A
|
Environment Variable: WATCHTOWER_DEBUG
|
||||||
Type: Boolean
|
Type: Boolean
|
||||||
Default: false
|
Default: false
|
||||||
```
|
```
|
||||||
|
@ -97,6 +97,16 @@ Environment Variable: WATCHTOWER_INCLUDE_STOPPED
|
||||||
Default: false
|
Default: false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Revive stopped
|
||||||
|
Start any stopped containers that have had their image updated. This argument is only usable with the `--include-stopped` argument.
|
||||||
|
|
||||||
|
```
|
||||||
|
Argument: --revive-stopped
|
||||||
|
Environment Variable: WATCHTOWER_REVIVE_STOPPED
|
||||||
|
Type: Boolean
|
||||||
|
Default: false
|
||||||
|
```
|
||||||
|
|
||||||
## Poll interval
|
## Poll interval
|
||||||
Poll interval (in seconds). This value controls how frequently watchtower will poll for new images.
|
Poll interval (in seconds). This value controls how frequently watchtower will poll for new images.
|
||||||
|
|
||||||
|
@ -127,6 +137,16 @@ Environment Variable: WATCHTOWER_MONITOR_ONLY
|
||||||
Default: false
|
Default: false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Without restarting containers
|
||||||
|
Do not restart containers after updating. This option can be useful when the start of the containers
|
||||||
|
is managed by an external system such as systemd.
|
||||||
|
```
|
||||||
|
Argument: --no-restart
|
||||||
|
Environment Variable: WATCHTOWER_NO_RESTART
|
||||||
|
Type: Boolean
|
||||||
|
Default: false
|
||||||
|
```
|
||||||
|
|
||||||
## Without pulling new images
|
## Without pulling new images
|
||||||
Do not pull new images. When this flag is specified, watchtower will not attempt to pull
|
Do not pull new images. When this flag is specified, watchtower will not attempt to pull
|
||||||
new images from the registry. Instead it will only monitor the local image cache for changes.
|
new images from the registry. Instead it will only monitor the local image cache for changes.
|
||||||
|
|
|
@ -32,6 +32,7 @@ To receive notifications by email, the following command-line options, or their
|
||||||
- `--notification-email-server-user` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER`): The username to authenticate with the SMTP server with.
|
- `--notification-email-server-user` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER`): The username to authenticate with the SMTP server with.
|
||||||
- `--notification-email-server-password` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD`): The password to authenticate with the SMTP server with.
|
- `--notification-email-server-password` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD`): The password to authenticate with the SMTP server with.
|
||||||
- `--notification-email-delay` (env. `WATCHTOWER_NOTIFICATION_EMAIL_DELAY`): Delay before sending notifications expressed in seconds.
|
- `--notification-email-delay` (env. `WATCHTOWER_NOTIFICATION_EMAIL_DELAY`): Delay before sending notifications expressed in seconds.
|
||||||
|
- `--notification-email-subjecttag` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SUBJECTTAG`): Prefix to include in the subject tag. Useful when running multiple watchtowers.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -59,7 +59,6 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20190403202508-8e1b8d32e692
|
golang.org/x/crypto v0.0.0-20190403202508-8e1b8d32e692
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
||||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
|
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
|
||||||
google.golang.org/appengine v1.4.0 // indirect
|
|
||||||
google.golang.org/genproto v0.0.0-20190401181712-f467c93bbac2
|
google.golang.org/genproto v0.0.0-20190401181712-f467c93bbac2
|
||||||
google.golang.org/grpc v1.21.0
|
google.golang.org/grpc v1.21.0
|
||||||
gotest.tools v2.2.0+incompatible // indirect
|
gotest.tools v2.2.0+incompatible // indirect
|
||||||
|
|
|
@ -94,6 +94,12 @@ func RegisterSystemFlags(rootCmd *cobra.Command) {
|
||||||
viper.GetBool("WATCHTOWER_INCLUDE_STOPPED"),
|
viper.GetBool("WATCHTOWER_INCLUDE_STOPPED"),
|
||||||
"Will also include created and exited containers")
|
"Will also include created and exited containers")
|
||||||
|
|
||||||
|
flags.BoolP(
|
||||||
|
"revive-stopped",
|
||||||
|
"",
|
||||||
|
viper.GetBool("WATCHTOWER_REVIVE_STOPPED"),
|
||||||
|
"Will also start stopped containers that were updated, if include-stopped is active")
|
||||||
|
|
||||||
flags.BoolP(
|
flags.BoolP(
|
||||||
"enable-lifecycle-hooks",
|
"enable-lifecycle-hooks",
|
||||||
"",
|
"",
|
||||||
|
@ -128,7 +134,7 @@ func RegisterNotificationFlags(rootCmd *cobra.Command) {
|
||||||
"",
|
"",
|
||||||
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_TO"),
|
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_TO"),
|
||||||
"Address to send notification emails to")
|
"Address to send notification emails to")
|
||||||
|
|
||||||
flags.IntP(
|
flags.IntP(
|
||||||
"notification-email-delay",
|
"notification-email-delay",
|
||||||
"",
|
"",
|
||||||
|
@ -168,6 +174,12 @@ Should only be used for testing.
|
||||||
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD"),
|
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD"),
|
||||||
"SMTP server password for sending notifications")
|
"SMTP server password for sending notifications")
|
||||||
|
|
||||||
|
flags.StringP(
|
||||||
|
"notification-email-subjecttag",
|
||||||
|
"",
|
||||||
|
viper.GetString("WATCHTOWER_NOTIFICATION_EMAIL_SUBJECTTAG"),
|
||||||
|
"Subject prefix tag for notifications via mail")
|
||||||
|
|
||||||
flags.StringP(
|
flags.StringP(
|
||||||
"notification-slack-hook-url",
|
"notification-slack-hook-url",
|
||||||
"",
|
"",
|
||||||
|
@ -232,6 +244,7 @@ func SetDefaults() {
|
||||||
viper.SetDefault("WATCHTOWER_NOTIFICATIONS", []string{})
|
viper.SetDefault("WATCHTOWER_NOTIFICATIONS", []string{})
|
||||||
viper.SetDefault("WATCHTOWER_NOTIFICATIONS_LEVEL", "info")
|
viper.SetDefault("WATCHTOWER_NOTIFICATIONS_LEVEL", "info")
|
||||||
viper.SetDefault("WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT", 25)
|
viper.SetDefault("WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT", 25)
|
||||||
|
viper.SetDefault("WATCHTOWER_NOTIFICATION_EMAIL_SUBJECTTAG", "")
|
||||||
viper.SetDefault("WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", "watchtower")
|
viper.SetDefault("WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", "watchtower")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,5 +19,6 @@ nav:
|
||||||
- 'Remote hosts': 'remote-hosts.md'
|
- 'Remote hosts': 'remote-hosts.md'
|
||||||
- 'Secure connections': 'secure-connections.md'
|
- 'Secure connections': 'secure-connections.md'
|
||||||
- 'Stop signals': 'stop-signals.md'
|
- 'Stop signals': 'stop-signals.md'
|
||||||
|
- 'Lifecycle hooks': 'lifecycle-hooks.md'
|
||||||
plugins:
|
plugins:
|
||||||
- search
|
- search
|
||||||
|
|
|
@ -38,7 +38,7 @@ type Client interface {
|
||||||
// * DOCKER_HOST the docker-engine host to send api requests to
|
// * DOCKER_HOST the docker-engine host to send api requests to
|
||||||
// * DOCKER_TLS_VERIFY whether to verify tls certificates
|
// * DOCKER_TLS_VERIFY whether to verify tls certificates
|
||||||
// * DOCKER_API_VERSION the minimum docker api version to work with
|
// * 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)
|
cli, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -50,6 +50,7 @@ func NewClient(pullImages bool, includeStopped bool, removeVolumes bool) Client
|
||||||
pullImages: pullImages,
|
pullImages: pullImages,
|
||||||
removeVolumes: removeVolumes,
|
removeVolumes: removeVolumes,
|
||||||
includeStopped: includeStopped,
|
includeStopped: includeStopped,
|
||||||
|
reviveStopped: reviveStopped,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ type dockerClient struct {
|
||||||
pullImages bool
|
pullImages bool
|
||||||
removeVolumes bool
|
removeVolumes bool
|
||||||
includeStopped bool
|
includeStopped bool
|
||||||
|
reviveStopped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client dockerClient) ListContainers(fn t.Filter) ([]Container, error) {
|
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
|
return createdContainer.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@ const (
|
||||||
// - It would only send errors
|
// - It would only send errors
|
||||||
// We work around that by holding on to log entries until the update cycle is done.
|
// We work around that by holding on to log entries until the update cycle is done.
|
||||||
type emailTypeNotifier struct {
|
type emailTypeNotifier struct {
|
||||||
From, To string
|
From, To string
|
||||||
Server, User, Password string
|
Server, User, Password, SubjectTag string
|
||||||
Port int
|
Port int
|
||||||
tlsSkipVerify bool
|
tlsSkipVerify bool
|
||||||
entries []*log.Entry
|
entries []*log.Entry
|
||||||
logLevels []log.Level
|
logLevels []log.Level
|
||||||
delay time.Duration
|
delay time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
|
func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifier {
|
||||||
|
@ -43,6 +43,7 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie
|
||||||
port, _ := flags.GetInt("notification-email-server-port")
|
port, _ := flags.GetInt("notification-email-server-port")
|
||||||
tlsSkipVerify, _ := flags.GetBool("notification-email-server-tls-skip-verify")
|
tlsSkipVerify, _ := flags.GetBool("notification-email-server-tls-skip-verify")
|
||||||
delay, _ := flags.GetInt("notification-email-delay")
|
delay, _ := flags.GetInt("notification-email-delay")
|
||||||
|
subjecttag, _ := flags.GetString("notification-email-subjecttag")
|
||||||
|
|
||||||
n := &emailTypeNotifier{
|
n := &emailTypeNotifier{
|
||||||
From: from,
|
From: from,
|
||||||
|
@ -54,6 +55,7 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie
|
||||||
tlsSkipVerify: tlsSkipVerify,
|
tlsSkipVerify: tlsSkipVerify,
|
||||||
logLevels: acceptedLogLevels,
|
logLevels: acceptedLogLevels,
|
||||||
delay: time.Duration(delay) * time.Second,
|
delay: time.Duration(delay) * time.Second,
|
||||||
|
SubjectTag: subjecttag,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.AddHook(n)
|
log.AddHook(n)
|
||||||
|
@ -62,7 +64,13 @@ func newEmailNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Notifie
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *emailTypeNotifier) buildMessage(entries []*log.Entry) []byte {
|
func (e *emailTypeNotifier) buildMessage(entries []*log.Entry) []byte {
|
||||||
emailSubject := "Watchtower updates"
|
var emailSubject string
|
||||||
|
|
||||||
|
if e.SubjectTag == "" {
|
||||||
|
emailSubject = "Watchtower updates"
|
||||||
|
} else {
|
||||||
|
emailSubject = e.SubjectTag + " Watchtower updates"
|
||||||
|
}
|
||||||
if hostname, err := os.Hostname(); err == nil {
|
if hostname, err := os.Hostname(); err == nil {
|
||||||
emailSubject += " on " + hostname
|
emailSubject += " on " + hostname
|
||||||
}
|
}
|
||||||
|
@ -128,7 +136,7 @@ func (e *emailTypeNotifier) SendNotification() {
|
||||||
time.Sleep(e.delay)
|
time.Sleep(e.delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
e.sendEntries(e.entries)
|
e.sendEntries(e.entries)
|
||||||
e.entries = nil
|
e.entries = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue