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,800 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,240 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,100 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

Is possible to have same k8s service for multiple pods?

Reserve a static IP and then assign ...READ MORE

answered Jul 20, 2018 in Kubernetes by Kalgi
• 37,320 points
0 votes
1 answer

How can I access a service installed on Kubernetes from anywhere?

I have followed the link which you have ...READ MORE

answered Jul 23, 2018 in Kubernetes by Atul
• 10,240 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