How to increase ulimit in Docker in Elastic Beanstalk?

泪湿孤枕 提交于 2021-02-19 08:52:16

问题


I would like to increase ulimit in Docker in Elastic Beanstalk to run some apps. I know that I need to increase ulimit of Docker host and restart docker service but cannot find a way to do it.

I wrote following .ebextensions/01limits.config but still cannot increase ulimit.

commands:
  01limits:
    command: echo -e "#commands\nroot soft nofile 65536\nroot hard nofile 65536\n* soft nofile 65536\n* hard nofile 65536" >> /etc/security/limits.conf
  02restartdocker:
    command: service docker restart

ADDED 2014-11-20 09:37 GMT

Also tried with following config file.

commands:
  01limits:
    command: echo -e "#commands\nroot soft nofile 65536\nroot hard nofile 65536\n* soft nofile 65536\n* hard nofile 65536" >> /etc/security/limits.conf
  02restartdocker:
    command: service docker stop && ulimit -a 65536 && service docker start

It successfully increased ulimit but showed following error in the management console:

[Instance: i-xxxxxxxx Module: AWSEBAutoScalingGroup ConfigSet: null] Command failed on instance. Return code: 1 Output: [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/00flip.sh] command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/enact/00flip.sh Stopping nginx: [ OK ] Starting nginx: [ OK ] Stopping current app container: 1c**********... Error response from daemon: Cannot destroy container 1c**********: Driver devicemapper failed to remove root filesystem 1c**************************************************************: Device is Busy 2014/11/20 09:06:36 Error: failed to remove one or more containers.

I am not sure this config is suitable.


回答1:


This is way late, but here's a (hopefully) working solution to your issue

initctl stop eb-docker && /sbin/service docker stop && ulimit -n 65536 && ulimit -c unlimited && export DMAP=$(df | grep /var/lib | awk '{print $1}') && if [[ $DMAP ]]; then umount $DMAP; fi && /sbin/service docker start && initctl start eb-docker

Explanation is as follows :

  • Stop docker container service
  • Stop docker service
  • Apply your ulimit settings (mine are different from yours)
  • Find offending devicemapper mount and unmount it (handles if none are mounted)
  • Start docker
  • Start docker container service

It's not an elegant solution, but such is the life of hacking around EB.

You might want to break it out into smaller components but the general idea is there.




回答2:


I was running a version of apachectl that was trying to change the file limit. And it was failing and causing an error with the container.

But, eventually, I ran the ulimit command from inside the container:

root@22806b77a474:/home# ulimit
unlimited

It seems apachectl was trying to raise a limit that isn't actually there in the docker container. I ULIMIT_MAX_FILES to something that didn't cause a problem.

RUN sed -i 's/ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-ulimit -n 8192}"/ULIMIT_MAX_FILES="ulimit -H -n"/' /usr/sbin/apachectl


来源:https://stackoverflow.com/questions/27007769/how-to-increase-ulimit-in-docker-in-elastic-beanstalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!