Skip to content

Rebalancing containers

Docker on MedStack Control

Docker on MedStack Control does not support automatic container rebalancing in an effort to prevent containers from unintentionally moving to a node that does not have the volume data it depends on. This has been done as a mitigation strategy while Docker on MedStack Control does not support persistent volume claims.

There are two (2) methods to rebalancing containers:

  • Rolling out a service update
  • Resetting service replicas (if there is no update to push)

Rolling out a service update

A service can be updated by:

  1. Hitting its unique webhook
  2. Sending a request to the /refresh_image endpoint for a service
  3. Introducing a change to the service configuration in the MedStack Control web application
  4. Introducing a change to the service configuration in the MedStack Control API

Resetting service replicas

Resetting the service replicas can be done by updating the service to have 0 replicas, and then issuing a second update to the desired number of replicas.

Example

In this scenario. there are 7 containers are running across 2 nodes.

5 containers are running on node A, and 2 containers are running on node B.

  • Set the service replica parameter to 0. All 7 containers to spin down.
  • After the containers have spun down, increase the service replicas to 7. All containers will spin up sequentially across all suitable nodes.

Ultimately, the Docker Manager node delegates which nodes are suitable for running containers upon container runtime based on the Swarm algorithm, node labels, and service placement constraints.

Rebalancing without introducing service interruption

Rebalancing can be done without introducing service interruption by decreasing the replica count to a value other than 0. This will keep at least 1 or more containers running. The replica can be set to the desired count to deploy the remaining containers on suitable nodes.