Closed pixeline closed 10 months ago
Hi @pixeline ,
To make this work you need to remove the USER nobody
line in the Dockerfile
so that supervisord runs as root.
And you also need to change the nobody
user in supervisord.conf
to root
.
I tried that but then it breaks the socket creation linking nginx and php-fpm
Hi @pixeline,
What's the exact error you get?
@TrafeX I'm having the same issue. So the only way to run cronjobs is to execute everything as root, am I correct?
@rauldeheer That's correct. I would not advise running a cronjob service in a container, but if you have no other option, this should do it.
@TrafeX What do you suggest instead? I don't think running everything as root is a good option to be honest.
I was able to make it work without using root. This is part of my Dockerfile
:
#Beginning of Dockerfile
RUN apk add --no-cache dcron libcap && \
chown nobody:nobody /usr/sbin/crond && \
setcap cap_setgid=ep /usr/sbin/crond
RUN echo '* * * * * php /var/www/html/bin/console system:worker' >> /etc/crontabs/nobody
RUN crontab -u nobody /etc/crontabs/nobody
RUN chown -R nobody /var/spool/cron/crontabs/nobody
RUN chmod 0644 /var/spool/cron/crontabs/nobody
COPY entrypoint.sh /scripts/entrypoint.sh
RUN chown -R nobody /scripts/entrypoint.sh
RUN chmod +x /scripts/entrypoint.sh
USER nobody
ENTRYPOINT ["/scripts/entrypoint.sh"]
entrypoint.sh
:
#!/bin/sh
/usr/sbin/crond -b
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
I am struggling to make cron work using supervisord as, if I understand correctly, crond needs to be ran by the
root
user.I tried to add this to supervisord.conf
and in the dockerfile
Does someone have a configuration that works?
Full dockerfile content: