The project runs under docker. Now there is a requirement for crontab. I want to add crontab under docker, but I find that it cannot be added. How do the experts who use docker add their own crontab under docker?
The project uses docker-compose 2.0
The system is equipped with ubuntu
The language is php7
My approach:
1. Install crontab in the Dockerfile.
2. Use the
volume
把本地的etc/crontab
file to map it in. Of course, you can also write it directly in the Dockerfile3, and use supervisor to start the main application and crontab
In fact, using crontab is nothing more than: installation, configuration, and startup. The first two steps are written directly in the Dockerfile when building. The key is how to start, because Docker only accepts one CMD and cannot start the main application and crontab at the same time. Just use supervisor.
1.Dockerfile is as follows
You can add to docker-compose to build
2. You can use other scripts to write a daemon program to simulate crontab implementation
3. Implement it on the host (not recommended)