Description
Hi, first of all: thanks for these great images, I really love them an use them a lot!
Problem definition
In one of my prod instances I'm using the image to run Shopware 5 in a Docker container. The system uses cron jobs to execute background jobs, so I'm using a docker-compose
configuration like this:
version: '3.3'
services:
app:
image: thecodingmachine/php:8.1-v4-apache
environment:
# Shopware cron
- CRON_USER=www-data
- CRON_SCHEDULE=*/5 * * * *
- CRON_COMMAND=php bin/console sw:cron:run
# ...
Which creates the following /tmp/generated_crontab
in the container:
*/5 * * * * sudo -E -u www-data -- bash -c 'php bin/console sw:cron:run'
After some days, my monitoring system complained about the increasing number of threads my server is using. I figured out, that these threads are related to zombie processes, which are obviously created by the containers Cron system. So if I check the processes from inside the container via
ps -ef
I get a lot of these entries:
root 75536 1 0 15:34 ? 00:00:00 [sudo] <defunct>
root 75581 1 0 15:39 ? 00:00:00 [sudo] <defunct>
root 75597 1 0 15:44 ? 00:00:00 [sudo] <defunct>
root 75611 1 0 15:49 ? 00:00:00 [sudo] <defunct>
root 75625 1 0 15:54 ? 00:00:00 [sudo] <defunct>
(note the 5 minutes difference which is exactly the cron frequency).
So to me it looks like the process started by sudo -E -u www-data -- bash -c 'php bin/console sw:cron:run'
is never really properly closed. Killing them manually is not possible because we'd need to kill the parent process, which is the containers root process with pid 1
.
Any ideas? Thanks for your help!
Possible Solution
Did not find a workaround to get rid of all the defunct
processes, yet. Think the only way would be to restart the container on a regular basis.
Your Environment
- Version used: 8.1 (see above)
- Operating System and version: Ubuntu 20.04 LTS
Activity