When attempting to set ulimit values inside Docker containers running on macOS using Docker Desktop, the following error occurs:
ulimit: error setting limit (Operation not permitted)
my init.sh file:
#! /bin/bash
set -e
ulimit -n 65536
service docker start
tail -f /dev/null
my dockerfile:
FROM ubuntu:latest
RUN apt update && apt upgrade -y
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update &&
apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release &&
rm -rf /var/lib/apt/lists/*
COPY init.sh /init.sh
RUN chmod +x /init.sh
ENTRYPOINT [“/init.sh”]
I should be able to start docker service inside my container, but i can’t. the ulimit: error setting limit (Operation not permitted) error occurs when attempting to set ulimit values within the Docker container on macOS. Since this restricts the ulimit execution in the kernel level, I think im missing something with configuring docker daemon to allow setting ulimits to the containers. since im using macOS, i cannot directly access the daemon.json file in my system. This issue persists even after restarting Docker Desktop and verifying Docker configuration settings.
Im using Macbook Air M2 with macOS sonoma 14.4 running docker engine v26.1.4