How to make `docker run` inherit ulimits
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 .
source to share
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"
source to share