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.
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
@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.
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.
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
cc @stffabi @bdehamer
@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?
馃檹
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.
Most helpful comment
Hi,
I successfully integrated watchtower into docker compose by specifying containers in the
commandsection like this:Like this only the containers
watchtower,nginx,nginx-genandpmawill be automatically updated.Cheers