-
Notifications
You must be signed in to change notification settings - Fork 854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watchtower not applying docker-compose configs:
after update
#1988
Comments
Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏 |
I have a similar problem. I am using a container launching system. ShinyProxy, this system launches user applications, of which we have a number of types. We are using docker swarm, and each application gets a user for each service. In the past we used Watchtower to monitor the images for updates, it killed the container pulled the image, and restarted the container. This worked OK, since a developer was using and testing it, the active apps would give error messages, and eventually the service would stop and ShinyProxy would launch a new container. However, ShinyProxy has since moved to preinitialized containers to avoid long container load times related to network swarm configurations. This presents a problem because restarted containers don't reattach to the service or ShinyProxy. ShinyProxy is smart enough now to realize that it needs to launch a new container after a developler loads the first one, however I feel this will leave stale services around. Is it possible to have some sort of clean up script run to stop the services associated with the containers. For nightly restarts, I have already set up some docker service stop commands. |
@kramerrs, I'm not sure that your issue is related to mine in any way. If ShinyProxy manages and preinitializes containers, then there's really no way for Watchtower to know how to replicate what ShinyProxy is doing. On the otherhand, docker-compose is a first-party solution meant to streamline management of containers in place of direct command-line calls. However, everything that compose does should be doable from the docker CLI, so Watchtower should be able to replicate it. In your case, I'd use linked containers flags to specify the relationships so that Watchtower does what you need it to do. I'm not familiar with ShinyProxy, but there may be a way for Watchtower to use lifecycle hooks to make calls to ShinyProxy to tell it how it should manage its containers. |
@Nick2253 Thank you for the suggestions. In this instance it would be sufficient to just to stop the service and or container, ShinyProxy is smart enough to relaunch containers and preinitialize them provided the images have been updated in the docker cache. I had seen the linked containers and lifecycle hooks, but it wasn't obvious how to accomplish this. I will go back and look at them some more. |
@kramerrs If all you need is for Watchtower to pull the latest images, then use the |
So I have been looking into fixing this, and have gotten rather sucked into the Watchtower rabbit hole. It seems Watchtower is naively restarting the containers, which makes sense from a purely Docker perspective. It gets more complicated when Compose is introduced into the mix, since it operates at a higher level of abstraction. I am not an expert on Docker (or Compose), but it seems Watchtower would need to have a concept of a Service, so that whenever a container image within a service is updated, all of the containers within that service are restarted with the updated image. This goes along with what @kramerrs said
I would imagine Watchtower could hook into Compose's APIs to restart the container within a service using the API equivalent of It also seems a number of other issues associated with Watchtower involve Watchtower-Compose interactions, and so it is possible doing this may fix some of the other issues. |
At the service level there are large number of things that can happen, Watchtower isn't the only software that doesn't handle these situations gracefully, as there is clearly better support for other systems, kubernetes etc. However, in a Docker framework it is sort of necessary to handle networking routing. For me I would be satisfied with a hook where I could run a script to do the orchestration of restarts. Watchtower has an elaborate hook system for pre/post launch etc. However, they appear to run within the launched container, which isn't really feasible as ShinyProxy needs to launch the containers, and I don't want to add these scripts to each container (dozens). Watchtower could pull the image, then run the script (in it's own container or another spun up container). I could then use docker to stop the service. Which is all I need. Others may have other requirements, though I think being able to run a script at that point would go a long way towards being able to manage services. As is, I have been able to work around and just kill the containers, it leaves stale services and containers, however I have a nightly cleanup script now, so developers are able to continue, and ShinyProxy has made their service more robust to finding dead containers spinning up new services. |
Describe the bug
I have a container created through
docker-compose
that is configured with aconfigs:
attribute in the compose file. After updating this container, the new container did not have the files specified inconfigs:
, and therefore failed to run appropriately.I had to redeploy the stack in order for the
configs
to be applied.Steps to reproduce
configs:
attribute.docker compose up
, and observe that the redeployed container now contains the appropriate files.Expected behavior
The newly created containers will be configured exactly as specified in the compose file.
Screenshots
No response
Environment
Your logs
Additional context
Minimal working example
docker-compose.yaml
file:If the
configs
is applied correctly, you should see the following in your nginx container log:The text was updated successfully, but these errors were encountered: