Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Docker Compose support #16

Closed
Closed

Description

@7imbrook

I don't know if you can do this or now, but I'd like to be able to specify the docker compose defined container name to watch, then have it do a rolling update on that. I could do this is regex matching or something, but I don't believe that's implemented. We can discuss this more more if you're interested.

Activity

  1. shyd commented on Jul 24, 2017

    @shyd

    Hi,
    I successfully integrated watchtower into docker compose by specifying containers in the command section like this:

    watchtower:
        image: v2tec/watchtower
        container_name: watchtower
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
          - /root/.docker/config.json:/config.json
        command: watchtower nginx nginx-gen pma --interval 30
        restart: unless-stopped

    Like this only the containers watchtower, nginx, nginx-gen and pmawill be automatically updated.

    Cheers

  2. olivierHa commented on Oct 25, 2017

    @olivierHa

    @shyd docker-compose is creating container with a "custom" name (based on the current repository for example)
    What @7imbrook wanted to do, is a way to "support" this custom name with watchtower, like putting a regexp instead of a container name for example.

  3. nderjung commented on Jan 8, 2018

    @nderjung

    I had success with watchtower observing containers defined within a docker-compose.yml context by enabling the --label-enable flag. Here's an example:

    services:
      watchtower:
        container_name: 'watchtower'
        image: v2tec/watchtower:0.2.1
        command: --cleanup --label-enable
        restart: always
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
          - ./etc/watchtower/config.json:/config.json:ro
      
      watchme:
        container_name: 'watchme'
        image: registry.example.com/watchme:latest
        restart: always
        labels:
          - com.centurylinklabs.watchtower.enable=true

    where ./etc/watchtower/config.json is a copy of the ~/.docker/config.json authentication configuration created after logging in to a registry with docker login registry.example.com.

  4. nderjung commented on Jan 8, 2018

    @nderjung

    My question is regard to observing a docker-compose.yml file for changes. Is there support for watchtower to observe changes to a set of services in a defined docker-compose.yml with watch tower running separately?

    For instance, if watchtower is spawned with:

    $ docker run --restart always \
      --volume ./etc/watchtower/config.json:/config.json:ro \
      watchtower --watch-services ./docker-compose.yml

    And then the file docker-compose.yml file is then observed for changes, and upon detected is re-started? (For example with docker-compose down && docker-compose up -d). Changes could occur independently via git-hooks, for example.

    The purpose of this is to enables greater control of the container parameters instead of simply updating the container itself. In the example below, this would allow the addition (and/or removal) of container parameters, such as the commands parameter, and the spawning of new containers, such as that defined by watchme2, if the following changes to the docker-compose.yml were to occur:

    services:
      watchme:
        container_name: 'watchme'
        image: registry.example.com/watchme:latest
        restart: always
    +   commands: --this-is-my-app-flag
        volumes:
          - watchme-data:/data
    
    + watchme2:
    +   container_name: 'watchme2'
    +   image: registry.example.com/watchme2:latest
    +   restart: always
  5. nderjung commented on Jan 8, 2018

    @nderjung
  6. simonaronsson commented on Apr 1, 2019

    @simonaronsson
    Collaborator

    @7imbrook
    what you're asking for is best resolved using enable labels, as pointed out in previous responses.

    @nderjung
    That's a great feature request. Unsure whether it would fit within the scope for watchtower however.

    Any suggestions on how we would go about doing this in practice? Maybe a two step solution where we first check the hash of the file and; in case it differs from the last seen; parse the yml for the actual changes? I guess you'd also like to use docker labels to tell watchtower whether a specific container should be automatically recreated or not?

    🙏

  7. simonaronsson commented on May 12, 2019

    @simonaronsson
    Collaborator

    the main question has been answered by @nderjung. if a compose file change trigger is still wanted, feel free to open up a new issue about that and/or provide a pull request implementing said feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions