Skip to content

cron won't run inside server container with custom uid #1899

Closed as not planned

Description

@meonkeys

I set up cron following https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/cron/apache . This has been working well for a while now. Just now I tried running my Nextcloud container as a non-root user (following #1812) and I'm getting an error from the container:

crond: can't set groups: Operation not permitted

Here's my Dockerfile:

FROM nextcloud:25.0.2-apache

RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    supervisor \
    ffmpeg \
    ghostscript \
    libmagickcore-6.q16-6-extra \
  && rm -rf /var/lib/apt/lists/* \
  && mkdir /var/log/supervisord /var/run/supervisord \
  && sed -i '/^.\+coder.\+PDF.\+$/s/none/read | write/' /etc/ImageMagick-6/policy.xml

COPY supervisord.conf /

# Avoid permission error later. This is likely suboptimal but it seems to work.
# The error is: PermissionError: [Errno 13] Permission denied: '/var/log/supervisord/supervisord.log'
RUN chown -R www-data:www-data /var/log/supervisord /var/run/supervisord

ENV NEXTCLOUD_UPDATE=1

CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

My workaround is to run the container as root.

See also:

Activity

  1. J0WI commented on Jan 17, 2023

    @J0WI
    Contributor

    duplicate of #1740

  2. meonkeys commented on Jan 17, 2023

    @meonkeys
    ContributorAuthor

    Thank you, "not planned" sounds fine, and we should add a note in the docs (I'll submit a patch). I don't think this is a dup of #1740 though. That issue is about running cron as a user the sysadmin chooses. This issue is, when running as a nonprivileged user, busybox's crond fails to run cron.php. I think the error message crond: can't set groups: Operation not permitted is coming from busybox's crond, which perhaps expects it is running as root. That would explain the likely attempt to drop permissions or whatever it is doing when it calls setgroups(). I didn't look to deep though, so I suppose some PHP code could be trying to call setgroups(). It does look like a busybox error message though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions