7

I am trying to create a docker image for Couchbase and i get the following error with the dockerfile on CentOS image.

# expose default port
EXPOSE 8091

ENV PATH $PATH:/opt/couchbase/bin

RUN cd /var/tmp &&\
    wget http://packages.couchbase.com/releases/2.5.0/couchbase-server-enterprise_2.5.0_x86_64.rpm &&\
    rpm -ivh couchbase-server-enterprise_2.5.0_x86_64.rpm &&\
    chkconfig couchbase-server on &&\
    service couchbase-server start

#add start script to the container
ADD start /start

#make the script executable
RUN chmod 0755 /start

EXPOSE 11211 11210 11209 4369 8092 18091 18092 11214 11215

#start mysql service and launch the command console
CMD ["/start"]

When building it, i am getting the following error ..

ulimit: open files: cannot modify limit: Operation not permitted
ulimit: max locked memory: cannot modify limit: Operation not permitted

I saw in a forum that we can set these values in docker.conf files. But i tried creating this file /etc/init/docker.conf and put the following lines in that file-

limit memlock unlimited unlimited limit nofile 262144

but still i get the same error.

If i follow the same steps manually on CentOS VM, it works. So i guess i need to set something on Docker CentOS image.

errordeveloper
  • 6,716
  • 6
  • 41
  • 54
cucucool
  • 3,777
  • 8
  • 48
  • 63

2 Answers2

7

Resolved the issue by setting the ulimit on the Docker host using the following command:

ulimit -l unlimited
ulimit -n 10240 
ulimit -c unlimited

Then restart the Docker service on the CentOS. That fixed the issue since these values of the host will be inherited by the container.

cucucool
  • 3,777
  • 8
  • 48
  • 63
  • on CentOS, add these commands to /etc/sysconfig/docker config file – mighq Oct 14 '15 at 15:46
  • 1
    These don't work on fargate/ecs `-bash: ulimit: max locked memory: cannot modify limit: Operation not permitted` – Shardj Feb 26 '20 at 15:21
1

Only root can increase the hard upper limit, and you have to be logged in as root, sudo won't work.

su root
ulimit -n 10240
blented
  • 2,699
  • 2
  • 23
  • 17