apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
Solution 1:
This might help:- http://ubuntuforums.org/showthread.php?p=11950245#post11950245
sudo service apache2 restart # no errors
service apache2 restart # errors
Solution 2:
The problem stems from /usr/sbin/apache2ctl (on Debian). Check it out:
~$ grep ULIMIT /usr/sbin/apache2ctl
ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-ulimit -n 8192}"
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
$ULIMIT_MAX_FILES
Here it is setting the number of open files allowed to 8192. Or trying to and failing, in your case.
So to avoid getting an error when apache2ctl does that, adjust your system's settings in the /etc/security/limits.conf file by adding these two lines:
* soft nofile 8192
* hard nofile 8192
I didn't increase it to more than necessary (8192) because I don't know what else it will impact. However this gets rid of the warning.
Not sure if you will need to reboot your system after that, because there is a dynamic element to the ulimits which I am not familiar with. However you can test easily enough to find out what your current ulimit num of files is:
ulimit -n
You might want to read where I found it: stackoverflow - setting ulimit
Solution 3:
1.Check and modify the value of ulimit in your host machine. Add the values in the file /etc/profile then make it take effect.
ulimit -u 10240
ulimit -n 8192 #This configuration is what we most needed
ulimit -d unlimited
ulimit -m unlimited
ulimit -s unlimited
ulimit -t unlimited
ulimit -v unlimited
source /etc/profile
or you can:
sudo sh -c 'printf "\nulimit -HSn 999999\n" >> /etc/sysconfig/docker'
2.Restart docker service and make the configuration to be effective.
sudo service docker restart
3.Test the ulimit in the container.
ulimit -n
This is my test result!
Tips:Maybe you can also try the command as below(prerequisite: ulimit in the host machine should be larger than 8192 ),but I am failed.
docker run --privileged -it -p xxxx:80 --ulimit data=8192 linode/lamp /bin/bash