0

I have an application that has 2 containers: a database and the middleware. I would like to use docker-compose to deploy this application to a docker swarm. Each container in my application depends on a 3rd-party license which applies per processor. What I'd like to do is lock each container to a specific node in the swarm which we have designated for the license (that is to say, all database containers should be on one node and all middleware containers should be on another). I can see how to do this from the docs, but the wrinkle that has me here today is that I'd like these containers to fail over to the other node in case of a failure of their preferred server. This is the only time it is acceptable for database containers to run on the middleware node and vice versa. Is it possible to accomplish this in Docker 17.09-ce (current as of the time of this question)?

Stuporman
  • 131
  • 6
  • You can add labels to specific node (see this [documentation](https://docs.docker.com/engine/swarm/manage-nodes/) and schedule containers on that specific node. AFAIK there is no "priority" / preference option in Docker swarm. You can create this logic yourself by creating a container for this which does monitoring and speaks to the [Docker Engine API](https://docs.docker.com/engine/api/v1.24/) – Devator Oct 04 '17 at 08:59
  • @Devator Would you be interested in submitting this as an answer that provides more detail on the API calls? – Stuporman Oct 04 '17 at 09:05
  • I do not have enough experience to post something and justify that as an answer, but I'd probably use a [socat proxy](https://hub.docker.com/r/rancher/socat-docker/) so you can use HTTP calls from any container to the docker swarm master (the socat proxy will need to have docker.sock mounted) as long as you have some sort of "management" network created. From there on, you can use CURL requests to perform actions on the Swarm. Make sure this "management" container can perform health checks (you need to create this yourself) to know when to spin up a container... – Devator Oct 04 '17 at 09:27

0 Answers0