The trick doesn't work with non-root users.
docker-compose.yml
:
services:
cron:
build: .
command: cron -f
Dockerfile
:
FROM ubuntu:23.04
COPY crontab .
RUN set -x \
&& apt-get update \
&& apt-get install cron \
&& useradd app \
&& crontab -u app crontab
crontab
:
* * * * * date >/proc/1/fd/1 2>/proc/1/fd/2
$ docker-compose up
(no output and date doesn't get executed)