Configure the resource limitations of containers

Docker Swarm

With orchestrator version 5.14, containers now have resource limits for memory and CPU by default. These limits can be seen by running the docker stats command on the machine where the orchestrator is installed. In the case of large instances, these limits may be too low. In this case, you can increase these limits by following the procedure below:

  1. Stop Cyberwatch

    sudo cyberwatch stop
    
  2. Edit or create the file /etc/cyberwatch/99-custom.yml Add new resource limits in the form:

    services:
      <CONTAINER>:
         deploy:
            resources:
              limits:
                cpus: '<CPU>'
                memory: '<MEMORY>'
    

    For example, to increase the memory limit of the db database container from the default from the default 8 GB to 10 GB:

    services:
      db:
        deploy:
          resources:
            limits:
              memory: '10G'
    

    Be careful not to set a value for CPU or memory higher than that proposed by the system, as Docker won’t be able to start the containers. An error will be displayed for impacted containers with the command sudo cyberwatch status.

  3. Start Cyberwatch

     sudo cyberwatch start
    
  4. Check the status of running containers:

     sudo cyberwatch status
    
  5. Check that the new limitations have been applied:

     docker stats
    

Back to top