Can I set ulimit for containers in k8s?

+1 vote

Any way i can set ulimit for containers in kubernetes?

Sep 14, 2018 in Kubernetes by shubham
• 6,890 points

4 answers to this question.

+1 vote

Since we use docker mostly for single processes, so there hasn't been an actual need for ulimit -u on it. On the other hand if you're just looking for resource limiting, kubernetes lets you do that. You can follow this doc:

answered Sep 14, 2018 by ajs3033
• 7,280 points
+1 vote

ssh into your Kubernetes cluster and modify the docker.service file. For an Amazon EKS cluster, the file is located at /usr/lib/systemd/system/docker.service. Append the property LimitMEMLOCK=infinity in the file and then restart docker using the following command

sudo service docker restart

This will spin up docker containers with an infinity memlock which is equivalent to

docker run -ulimit memlock=-1:-1 <docker image>
answered May 7 by Umer
+1 vote

You can set a DaemonSet with a privileged container setting the hosts ulimit. Something like this:


    image: image-name
    command: ["sh", "-c", "ulimit -n 65536"]
      privileged: true
answered May 7 by Alok
+1 vote

You can either modify them via UserData for worker AutoScalingGroup (when using EKS AMI) or by building your own AMI.

Something like:

sudo sed -i "s|ExecStart=.*|ExecStart=/usr/bin/dockerd --default-ulimit memlock=83968000:83968000|g" /usr/lib/systemd/system/docker.service

sudo systemctl restart docker.service
answered May 7 by Inayat

Related Questions In Kubernetes

0 votes
1 answer

Can I run docker containers on different machines?

Yes, but you should also: create the relevant libnetworks in ...READ MORE

answered Oct 17, 2018 in Kubernetes by lina
• 8,110 points
0 votes
1 answer

How do I set up a k8s cluster on windows?

Hey @Nadia, follow these steps to create ...READ MORE

answered Feb 25 in Kubernetes by Roshan
0 votes
1 answer

Can I configure my kubernetes job to run for a specified time?

When we create a job spec, we ...READ MORE

answered Jul 17 in Kubernetes by Sirajul
• 36,620 points
0 votes
1 answer

how can i access two containers that are inside a pod from the browser with IP address?

Just do port forward. kubectl port-forward [nginx-pod-name] 80:80 kubectl ...READ MORE

answered Jul 18 in Kubernetes by Sirajul
• 36,620 points
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
0 votes
2 answers