亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

dcoker-compose - How to execute crontab under docker
習(xí)慣沉默
習(xí)慣沉默 2017-05-24 11:32:55
0
2
1210

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

習(xí)慣沉默
習(xí)慣沉默

reply all(2)
劉奇

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 Dockerfile
3, 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.

PHPzhong

1.Dockerfile is as follows

FROM centos
MAINTAINER zhaojunlike<zhaojunlike@gmail.com>
ADD ./crond/task.sh /server/task.sh
##安裝并添加任務(wù)到crontab
RUN yum install crontabs -y \
    && (crontab -l; echo "*/1 * * * * /server/task.sh >>/var/log/task.log" ) | crontab
CMD crond

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)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template