GithubHelp home page GithubHelp logo

Docker Compose support about watchtower HOT 7 CLOSED

containrrr avatar containrrr commented on May 22, 2024 39
Docker Compose support

from watchtower.

Comments (7)

shyd avatar shyd commented on May 22, 2024 36

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

from watchtower.

nderjung avatar nderjung commented on May 22, 2024 20

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.

from watchtower.

nderjung avatar nderjung commented on May 22, 2024 8

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

from watchtower.

olivierHa avatar olivierHa commented on May 22, 2024 1

@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.

from watchtower.

nderjung avatar nderjung commented on May 22, 2024

cc @stffabi @bdehamer

from watchtower.

simskij avatar simskij commented on May 22, 2024

@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?

🙏

from watchtower.

simskij avatar simskij commented on May 22, 2024

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.

from watchtower.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.