Description
Bug Overview
Hi,
I have a project using unit:1.34.1-php8.4. I am testing it in docker, along with redis, and mysql. Everything is working fine, except the php container memory usage keeps increasing.
Docker-compose.yml
services:
php:
build:
context: .
dockerfile: Dockerfile
working_dir: /var/www/html/
container_name: phpApp
ports:
- '80:80'
- '443:443'
volumes:
- '.:/var/www/html/'
networks:
- default
Dockerfile
RUN apt-get update \
&& curl -s https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer
RUN apt-get update && apt-get install -y \
libonig-dev \
libxml2-dev \
&& docker-php-ext-install pcntl
RUN pecl install redis \
&& docker-php-ext-enable redis
RUN apt-get update && apt-get install -y supervisor
COPY config/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
WORKDIR /var/www/html/
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY config/config.json init.json
COPY config/cert-bundle.pem init.pem
RUN nohup /bin/sh -c "unitd --no-daemon --pid init.pid --log /dev/stdout --control unix:init.unit.sock &" && \
# Wait for Unit to start (a few seconds to be sure)
sleep 5 && \
# Check if the socket is available
curl --unix-socket init.unit.sock -fsX GET _/config && \
curl -fsX PUT --data-binary @init.pem --unix-socket init.unit.sock _/certificates/cert-bundle && \
curl -fsX PUT [email protected] --unix-socket init.unit.sock _/config && \
rm init.*
EXPOSE 80 443
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
docker status start like below.

When it is exposed to traffic, the memory for phpApp slowly starts to rise. Say, it goes from 120MB at start, to ~400MB in 12 hours or so. And keeps going, to the point the container gets restarted.
This is with traffic, after some time

Trying to narrow down to what might be causing this, I have identified a process in the process list that shows notable cpu usage (3-4%, while the others are in the 1.x %). In the below screenshot, pid 15 is the one I am referring to.

Looking into this process, I could see a lot of entries, trying to access the base machine, with permission denied. Adding
privileged: true
to the docker-compose file for the phpApp got rid of this error, and I could see a bunch of entries like below


Note that, even when I was seeing all those Permission denied entries under PID15, the app is running fine, so it is not affecting the app. If I kill this process, the memory usage comes down instantly.

But another process spawns and starts doing the same thing.
Expected Behavior
Memory usage should remain more or less same for a constant load. But it keeps increasing.
Steps to Reproduce the Bug
I use docker-compose up command to start the containers on AWS EC2.
Environment Details
- Target deployment platform: [AWS]
- Target OS: [Amazon Linux 2023]
- Version of any relevant project languages: [php8.4]
Additional Context
Any help is much appreciated. I can provide any additional info (config.json, supervisor.conf etc if needed).