How to make `docker run` inherit ulimits

Executing a command through docker doesn't look like my currently configured ulimit

s:

$ ulimit -t
five
~ $ sudo - bash -c "ulimit -t"
five
~ $ sudo - docker run --rm debian: wheezy bash -c "ulimit -t"
unlimited

How can I do it?

+3


source to share


2 answers


You can set global limits in the Docker daemon configuration. On Ubuntu, this is managed in Upstart. Add limit cpu <softlimit> <hardlimit>

to /etc/init/docker.conf

and restart the daemon.

In each container, you must use the --privileged

c flag docker run

to set the ulimits. AFAIK there is no way to do this without --privileged

.



See also Runtime Limits for CPU and Memory .

+1


source


Currently (v1.5.0) these limits are inherited from the docker daemon limits. But the docker team is going to release limits on each container .

For a workaround, you can set limits inside the container like



# docker run ubuntu bash -c "ulimit -t 5; doSomething"

      

0


source







All Articles