Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Last active February 5, 2023 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x-yuri/336fd3185de7e168023867302d5ac99b to your computer and use it in GitHub Desktop.
Save x-yuri/336fd3185de7e168023867302d5ac99b to your computer and use it in GitHub Desktop.
docker + cron + /proc/1/fd

docker + cron + /proc/1/fd

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment