Comments (7)
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 pma
will be automatically updated.
Cheers
from watchtower.
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.
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.
@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.
from watchtower.
@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.
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)
- Set a fixed time instead of a timer HOT 6
- Send notification containing Image Label HOT 1
- Telegram notification HOT 3
- Stopping containers doesn't work on Ubuntu 23.10 HOT 22
- Parsed container image ref has no tag HOT 2
- Quoted env variables don't work when containing comma HOT 5
- SMTP timeout error with Outlook email notifications HOT 1
- FR: Multiple Hosts Support HOT 3
- Wont update aio-imaginary HOT 1
- Delete content of config.json upon every restart HOT 1
- API error when using hostname HOT 1
- Watchtower failed to create containers on host network HOT 30
- Clean formatting for email notifications HOT 1
- level=fatal msg="Failed to initialize Shoutrrr notifications: error initializing router services: failed to log in: Too Many Requests\n" HOT 2
- Container with macvlan IP uses wrong IP after recreation HOT 4
- On error print recreate command HOT 4
- Failed to parse int from \"0: strconv.Atoi: parsing \"\\\"0\": invalid syntax" HOT 3
- Discord notifications changed format HOT 2
- Could not restart auto-removing containers HOT 1
- Update/Downgrade an container to a specific tag via http api mode HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from watchtower.