Interview Prep/Real-World Interview/Write-a-Dockerfile tasks

Write a Dockerfile for a cron-style job container that runs a script once and exits.

BeginnerHands-onWrite-a-Dockerfile tasks
Answer
FROM alpine:3.20
RUN apk add --no-cache bash curl jq aws-cli
COPY --chmod=0755 backup.sh /usr/local/bin/backup.sh
USER 65534:65534
ENTRYPOINT ["/usr/local/bin/backup.sh"]

Key trick → Don't run crond inside the container. Let the scheduler (a Kubernetes CronJob or an EventBridge rule plus ECS task) start it, and let the exit code report success. COPY --chmod avoids an extra RUN chmod layer.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-Dockerfile tasks