Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Restart a docker container when it is higher than from a certain of memory limitation?

I want to have a policy in my docker-compose which a docker container memory usage will be higher than the amount of a certain memory limitation it restarts.

This is what I have done so far:

version: '3'

services:
    modbus_collector:
        build: .
        image: modbus_collector:2.0.0
        container_name: modbus_collector
        restart: unless-stopped
        deploy:
          resources:
            limits:
              memory: 28M

I was expecting that to be restarted when the container memory usage exceeds 28M, but when I monitor docker containers by docker stats I see that this container memory usage grow up and not happens about restart!

I also tried by restart: always but the result was the same.


[UPDATE]:

With version 2 it works fine with mem_limit:. But it fails while using version 3, putting them under deploy section doesn't seem worthy unless I am using swarm mode.

Even on version 2.1, I have a problem in restarting the container: limitation applied correctly, but when the container memory usage grows up, this limitation prevents of that but I expected instead of decrease memory it will restart that container.

version: '2.1'

services:
    modbus_collector:
        build: .
        image: modbus_collector:2.0.0
        container_name: modbus_collector
        restart: unless-stopped
        mem_limit: 28m
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!