16
How to run a cron as a non-root user in Docker 🦾
Yesterday, I was looking to add a cron to an existing Docker image, but it took longer than I would like. Even though I previously had a recipe for adding a cron to a Docker image, I had new contraints that made this solution unsuitable... 😐
Let's go over all the constraints I had:
- Using a Debian-based image
- The user running the image is a unprivileged user
- The cron is not the only process
- There is an entrypoint script
After searching on the internet, I finally found a working solution with the help of this Stack Overflow answer. So if anyone needs it, this article could serve as a reference. 😁
I hope again it will helps you as well! 😎
Make sure to replace APPLICATION
by the directory you want and NON_ROOT_USER
by the name of your unprivileged user. 😉
16