Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using non root user #2

Open
nbraun-wolf opened this issue Aug 22, 2021 · 1 comment
Open

using non root user #2

nbraun-wolf opened this issue Aug 22, 2021 · 1 comment

Comments

@nbraun-wolf
Copy link

nbraun-wolf commented Aug 22, 2021

Hi, thanks for this repo. It's really useful. I have one problem though. I want to use a non-root user in the image. Do you have any idea how this could be done?

I get some error like this:

crond[11]: can't set groups: Operation not permitted

More Info

Dockerfile

FROM python:3.8-alpine

ENV PYTHONPATH /opt/app

RUN rm -rf /etc/periodic
COPY entrypoint.sh /usr/bin/
COPY cronjob /var/spool/cron/crontabs/root

ARG UID=9000
ARG USER=uwsgi
RUN adduser \
    --disabled-password \
    --gecos "" \
    --home ${PYTHONPATH} \
    --no-create-home \
    --uid ${UID} \
    ${USER}

RUN touch /etc/environment
RUN chown ${UID}:${UID} /etc/environment

WORKDIR ${PYTHONPATH}
COPY cmd.sh .
USER ${USER}

ENTRYPOINT [ "entrypoint.sh" ]
CMD [ "./cmd.sh" ]

entrypoint.sh

#!/bin/sh

set -ex

env >> /etc/environment
crond -l 2

exec "$@"

cronjob

*   *   *   *   *   date

cmd.sh

#!/bin/sh

while true;
do
    echo "running"
    sleep 12
done

Related Links

I found one old question on SO regarding this:
https://stackoverflow.com/questions/53103621/how-to-start-crond-as-non-root-user-in-a-docker-container

@jacobbeasley
Copy link

I've seen people use this - https://github.com/odise/go-cron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants