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

407
Views
How to kill a docker container when it reaches set of memory usage or CPU limit

I have a docker container which running in a pod where I need to restart the pod / container when it exceeds memory usage or CPU limit. How to configure it in docker file

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

CPU and memory limits cannot be given when building a docker and it cannot be configured in Docker File. It is a scheduling problem. You could run your docker with docker run command with different flags to control resources. See Docker Official Document for those control flags for docker run.

As your question is tagged with kubernetes, there is kubernetes way to limit your resources. You would want to add resources in specs for those deployment or pod yaml. For example:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: your_deployment
  labels:
    app: your_app
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: your_app
    spec:
      containers:
      - name: your_container
        image: your_image
        resources:
          limits:
            cpu: "500m"
            memory: "128Mi"
          requests:
            cpu: "250m"
            memory: "64Mi"
        ...

requests affects how docker pod is scheduled on nodes. Memory limit determines when the docker will be killed for OOM and cpu limit determines how the container cpu usage will be throttled (The pod will not be killed).

Meaning of cpu is different for each cloud service providers. For more information, please refer to manage compute resources for Kubernetes

over 4 years ago · Santiago Trujillo Report
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!