Question

A php application on docker works fine on Ubuntu 23.10 but crashes on 24.04

I have the following docker configuration for Mautic (A PHP based CRM):

x-mautic-volumes:
  &mautic-volumes
  - ./mautic/config:/var/www/html/config:z
  - ./mautic/logs:/var/www/html/var/logs:z
  - ./mautic/media/files:/var/www/html/docroot/media/files:z
  - ./mautic/media/images:/var/www/html/docroot/media/images:z
  - ./mautic/themes/leeway_newsletter:/var/www/html/docroot/themes/leeway_newsletter:z
  - ./mautic/themes/leeway_responsive:/var/www/html/docroot/themes/leeway_responsive:z
  - ./session.ini:/usr/local/etc/php/conf.d/session.ini:z
  - ./cron:/opt/mautic/cron:z
  - mautic-docroot:/var/www/html/docroot:z
  - mautic-vendor:/var/www/html/vendor:z

services:
  nginx:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - mautic-docroot:/var/www/html/docroot:z
      - ./mautic/media/files:/var/www/html/docroot/media/files:z
      - ./mautic/media/images:/var/www/html/docroot/media/images:z
      - ./.well-known:/var/www/html/docroot/.well-known
    depends_on:
      - web
    ports:
      - "127.0.0.1:8002:80"
    networks:
      - default
    restart: always

  web:
    image: my_mautic:5.2.1
    build: .
    volumes: *mautic-volumes

    env_file:
      - .mautic_env
    healthcheck:
      test: cgi-fcgi -bind -connect 127.0.0.1:9000
      start_period: 5s
      interval: 5s
      timeout: 5s
      retries: 100
    networks:
      - default
    restart: always

  cron:
    image: my_mautic:5.2.1
    build: .
    volumes: *mautic-volumes
    environment:
      - DOCKER_MAUTIC_ROLE=mautic_cron
    env_file:
      - .mautic_env
    depends_on:
      web:
        condition: service_healthy
    networks:
      - default
    restart: always

volumes:
  mautic-docroot:
    name: mautic-5.2.1
  mautic-vendor:
    name: mautic-5.2.1-vendor

networks:
  default:
    name: ${COMPOSE_PROJECT_NAME}-docker

This application is accessed through an NginX that takes care of SSL and forwards traffic to both this docker container and a regular WordPress hosted directly on the server using php8.2-fpm.

I have my servers on Basic Premium Intel droplets (1 GB Ram, 1vCPU, 25GB disk).

The app is currently running just fine on an Ubuntu 23.10 server.

I tried to put together a new server using Ubuntu 24.04 and, using the exact same configuration, after running for about 20 minutes, the CPU usage will go to 100% and stay there until I manually kill the in-docker php-fpm process.

I tried installing docker from the official sources, re-install the whole thing from scratch to make sure I wasn’t using old volumes, explicitly limited resources for the web container but I always end up in the same place.

Any idea?

Thanks!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
January 22, 2025

Hello, @maurochojrin

You can use tools like htop or iotop to identify bottlenecks:

It will be useful to check if a process outside Docker is interfering with PHP-FPM. Also you can monitor which exct process is consuming the CPU and memory on the droplet. This willl give you insight which configuration you can tweak - php-fpm, nginx and etc.

The high CPU usage is likely due to an issue with PHP-FPM or the Mautic app’s handling of requests:

Inspect the PHP-FPM logs within the container to identify errors or repetitive processes. Look for:

  • Too many processes being spawned (pm.max_children being exceeded).
  • High request durations or slow script execution.

Also there might be a high disk usage or slow reads/writes could cause processes to hang.

Hope that this helps!

KFSys
Site Moderator
Site Moderator badge
January 22, 2025

If you issue comes from the php-fpm proccesses that are being spawned, you’ll need to tweak them a little bit.

pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500

Try something like the above.

Now, I am also baffled about why it’s happening on Ubuntu 24.04. The only thing I can think of is that maybe there are some differences between the versions which lead to this.

  • Resource Limits: Check and compare cgroup settings, ulimits, and file system configurations.
  • Dependencies: Compare installed libraries and dependencies across both system. Ensure SELinux/AppArmor settings are not overly restrictive as well.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.