How to increase number of open files in Azure ARM template for container instance

Vasyl Moskalov 0 Reputation points
2023-04-06T04:32:27.67+00:00

During running my container instance I received a "too many files" error. How I can increase the hard and/or soft number of file limits?

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
669 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Kenneth Gonzalez Pineda 5 Reputation points Microsoft Employee
    2023-06-01T17:48:33.3066667+00:00

    Hello all, I wanted to clarify this issue. Proposed solutions are based on GPT search results that seem invalid. There is no ulimits CLI parameter nor ResourceLimit in ACI API for ARM templates. I was provided with an invalid ARM template by GPT as well. Issue with GPT is that we always have to validate answers, it works by processing natural language and similarities, this probably why it's making wrong suggestions. The templates and commands probably are similar to others that are valid in other scopes. If interesting in reading more, search online why ChatGPT can't multiply small numbers correctly, this is because it bases the answer in "similar" operations and results it has read.

    Now, speaking of the request, there is no way to alter ulimits in ACI. This is a security feature based in container runtime, it would be bad for a container to change these limits in the host. The runtime takes the value from host, so, this is also true even in Kubernetes (open issue since 2015: https://github.com/kubernetes/kubernetes/issues/3595). In other words, the only way to increase this limit for a container is to increase it at OS level at host. This is not available in ACI, to overcome this issue you may try AKS and change this limit in the nodes via daemonset.

    1 person found this answer helpful.

  2. vipullag-MSFT 25,611 Reputation points
    2023-05-08T10:36:45.4966667+00:00

    Hello Vasyl Moskalov

    Firstly, apologies for the delay in responding here and any inconvenience this issue may have caused.

    Use a custom init container to modify the limits of the container instance. You can create a custom init container that runs before your main container and sets the limits using the ulimit command. Here is an example of how to set the hard and soft limits for the number of open files to 65535 in an init container:

    
    apiVersion: v1
    
    kind: Pod
    
    metadata:
    
      name: my-pod
    
    spec:
    
      initContainers:
    
      - name: init-container
    
        image: alpine
    
        command: ["sh", "-c", "ulimit -n 65535"]
    
        resources:
    
          limits:
    
            cpu: 100m
    
            memory: 128Mi
    
          requests:
    
            cpu: 100m
    
            memory: 128Mi
    
      containers:
    
      - name: my-container
    
        image: my-image
    
        resources:
    
          limits:
    
            cpu: 1
    
            memory: 1Gi
    
          requests:
    
            cpu: 100m
    
            memory: 128Mi
    
     
    
    
    
    

    In this example, the initContainers section defines an init container that sets the nofile limit to 65535 using the ulimit command. The containers section defines the main container that runs after the init container.

    Hope this helps.

    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.


  3. Brijan Elwadhi 0 Reputation points
    2023-07-06T11:28:34.5766667+00:00

    Hi, I am facing the similar issue. And I can't find anything in the documentation for fileHandles.