Watchtower: label com.centurylinklabs.watchtower.enable=false is ignored

Created on 3 Sep 2018  ·  17Comments  ·  Source: containrrr/watchtower

Running a container with the com.centurylinklabs.watchtower.enable set to false seems to be ignored...

docker run -dit \
  ...
  --label=com.centurylinklabs.watchtower.enable=false \
  nodered/node-red-docker:slim-v8

docker run -it --rm \
  --name watchtower \
  -v /home/ms/.docker/config.json:/config.json \
  -v /var/run/docker.sock:/var/run/docker.sock \
  v2tec/watchtower --debug

Confirm label with docker inspect:

"Labels": {
                "com.centurylinklabs.watchtower.enable": "false"
            }

watchtower ignores the label...

DEBU[0000] Retrieving running containers
INFO[0000] First run: 2018-09-03 17:02:53 +0000 UTC
DEBU[0299] Checking containers for updated images
DEBU[0299] Retrieving running containers
DEBU[0299] Pulling nodered/node-red-docker:slim-v8 for /node-red
DEBU[0299] No credentials for nodered in /config.json
DEBU[0299] No authentication credentials found for nodered/node-red-docker:slim-v8
DEBU[0299] No new images found for /node-red
Bug

Most helpful comment

There was another post about just building an image; which is what I did

FROM golang:alpine as builder
RUN apk update && apk add  alpine-sdk ca-certificates tzdata
RUN curl https://glide.sh/get | sh

RUN go get github.com/v2tec/watchtower; exit 0

WORKDIR /go/src/github.com/v2tec/watchtower

RUN glide install

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo .

FROM scratch

LABEL "com.centurylinklabs.watchtower"="true"

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /go/src/github.com/v2tec/watchtower/watchtower /watchtower

ENTRYPOINT ["/watchtower"] 

All 17 comments

I agree, it does not work. This is because watchtower was never built/pushed to the docker hub after they changed the code and updated the readme.
Not sure what their build schedule is.

I've created a simple docker container using the current watchtower version from github: https://hub.docker.com/r/svengo/watchtower/. You can find the Dockerfile on github.

I should add a README...

There was another post about just building an image; which is what I did

FROM golang:alpine as builder
RUN apk update && apk add  alpine-sdk ca-certificates tzdata
RUN curl https://glide.sh/get | sh

RUN go get github.com/v2tec/watchtower; exit 0

WORKDIR /go/src/github.com/v2tec/watchtower

RUN glide install

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo .

FROM scratch

LABEL "com.centurylinklabs.watchtower"="true"

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /go/src/github.com/v2tec/watchtower/watchtower /watchtower

ENTRYPOINT ["/watchtower"] 

Would be great if a new image could be pushed. It's a little confusing for anyone trying to use labels :)

222

Labels work fine - however you don't appear to be passing "--label-enable" to watchtower on the command line.

Labels work fine - however you don't appear to be passing "--label-enable" to watchtower on the command line.

Incorrect.
From the Readme.md:

Selectively Watching Containers
By default, watchtower will watch all containers. However, sometimes only some containers should be updated.

If you need to exclude some containers, set the com.centurylinklabs.watchtower.enable label to false.

LABEL com.centurylinklabs.watchtower.enable="false"
Or, it can be specified as part of the docker run command line:

docker run -d --label=com.centurylinklabs.watchtower.enable=false someimage

No "--label-enable" needs nor should be set.

If you need to only include only some containers, pass the --label-enable flag on startup and set the com.centurylinklabs.watchtower.enable label with a value of true for the containers you want to watch.

Just discovered this – interesting there hasn’t been an update in 4 months…

I tried to exclude my Nextcloud instance from being updated, but it got updated still.

Now I find this bug report and it's really confusing.

Documentation talks about labelling containers with com.centurylinklabs.watchtower.enable=false.

But then in watchtower's very own Dockerfile there's a label com.centurylinklabs.watchtower.

Is this serving a different purpose? Is this a typo? Are both labels achieving the same?

It may not work because of a typo in the code

In container.go line 15, the name of the variable is "enableLabel"
enableLabel = "com.centurylinklabs.watchtower.enable"
https://github.com/v2tec/watchtower/blob/master/container/container.go#L15

but in the filter function (filters.go line 54) the variable "enabledLabel" is used
enabledLabel, ok := c.Enabled()
https://github.com/v2tec/watchtower/blob/8197bb669d2f3c992a094572c455cc71f6b866a8/container/filters.go#L54

just verified that this actually does work using --label "com.centurylinklabs.watchtower.enable=false" running the latest watchtower release.

the variable naming pointed out by @untergrundbiber is valid as it's scope local and as such; does not result in any error.

the label mentioned by @sebw is used to point out which container's the actual watchtower.

I was still experiencing this until I realised I was using v2tec/watchtower and not containrrr/watchtower so now this feature is working nicely!

Great! Wohoo!

Hi,
I run into the same issue. I did check that I really use the conatinrrr image and that the label on container of interest is set. The main difference is that I'm using the build section from docker-compose

    $ cat ~/docker-compose/watchtower/docker-compose.yml 
    # watchtower
    version: '3'

    services:
      # [containrrr/watchtower](https://github.com/containrrr/watchtower)
      # for help, use:
      # $ sudo docker run --rm containrrr/watchtower --help
      watchtower:
        image: 
          containrrr/watchtower
        command:
          --no-startup-message --cleanup
        restart:
           always
        volumes:
          - ./certs:/etc/ssl/certs
          - /var/run/docker.sock:/var/run/docker.sock
        environment:
          - TZ='Europe/Berlin'
          - WATCHTOWER_NOTIFICATIONS=email
          - [email protected]
          - [email protected]
          - WATCHTOWER_NOTIFICATION_EMAIL_SERVER=mail.example.com
          - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=25
          - WATCHTOWER_NOTIFICATION_EMAIL_DELAY=3
          - WATCHTOWER_POLL_INTERVAL=300  # default: 300

    $ cat ~/docker-compose/0staging/logging/docker-compose.yml
    # Docker Container Logging Stack
    version: "3"

    services:
      # [fluent/fluentd](https://hub.docker.com/r/fluent/fluentd)
      fluentd:
        build:
          # https://hub.docker.com/r/fluent/fluentd doesn't have
          # elastic search plugin installed, so build it for our own
          ./fluentd
        networks:
          - default
        ports:
          - "127.0.0.1:24224:24224"
          - "127.0.0.1:24224:24224/udp"
        volumes:
          - ./fluent.conf:/fluentd/etc/fluent.conf
        labels:
          - com.centurylinklabs.watchtower.enable=false
        depends_on:
          - elasticsearch
      ...

Now I get all the time email:

    Subject: Watchtower updates on 83d50ac31a6f
    From: [email protected] (May 1, 2020 8:26 AM)
    To: [email protected]

    2020-05-01 06:26:10 (info): Unable to update container /logging_fluentd_1. Proceeding to next.

BTW; how to get real hostnames or even docker's image names into the subject?

@opelx can you double-check the compose label syntax?

According to docker-compose labels docs, the following syntaxes are accepted:

labels:
    com.example.description: "Accounting webapp"
    com.example.department: "Finance"
    com.example.label-with-empty-value: ""

or

labels:
    - "com.example.description=Accounting webapp"
    - "com.example.department=Finance"
    - "com.example.label-with-empty-value"

Maybe wrapping com.centurylinklabs.watchtower.enable=false up with quotes might solve the issue.

Let me know if the problem persists xD

Just discovered this – interesting there hasn’t been an update in 4 months…

Yeah, sorry about that. This is an open source project without corporate sponsorship, and as such we all do this in our spare time. Feel free to lend a hand or contribute financially if you think the velocity is too low. 😅

it seems that fixes the issue, I haven't faced this issue since.
Thanks!

Locking this issue as it obviously works, as confirmed by @opelx. If you still have problems, create a new issue and provide debug logs, as well as your docker compose config. Thanks for understanding. 🙏🏼

Was this page helpful?
0 / 5 - 0 ratings

Related issues

7imbrook picture 7imbrook  ·  7Comments

Ezwen picture Ezwen  ·  6Comments

andreo picture andreo  ·  6Comments

alexhaller picture alexhaller  ·  3Comments

simskij picture simskij  ·  5Comments