Cron作业中断docker中的其他前台服务器

Cron作业中断docker中的其他前台服务器,cron,docker,dockerfile,docker-compose,Cron,Docker,Dockerfile,Docker Compose,为了在启动时启动selenium服务器 我必须把入口点.sh放在/opt/bin 但是如果我取消对cron命令的注释CMD cron&&tail-f/var/log/cron.log 服务器将不再运行 我不明白它为什么会坏 这是我的cron文件 这是我的docker文件 更新entry_point.sh 您的entrypoint脚本需要从entrypoint或CMD指令调用,否则在容器启动时将无法运行 在启动应用程序之前,需要从entrypoint脚本中删除CMD并启动cron。您可能希望使用进

为了在启动时启动selenium服务器

我必须把
入口点.sh
放在
/opt/bin

但是如果我取消对cron命令的注释
CMD cron&&tail-f/var/log/cron.log

服务器将不再运行

我不明白它为什么会坏

这是我的cron文件 这是我的docker文件 更新entry_point.sh
您的entrypoint脚本需要从
entrypoint
CMD
指令调用,否则在容器启动时将无法运行


在启动应用程序之前,需要从entrypoint脚本中删除
CMD
并启动cron。您可能希望使用进程管理器(如runit或supervisord)来处理此问题(请参阅)。

谢谢,但我尝试了您的解决方案,它可能不起作用,进程将卡在
cron
上,而不运行
xvfb run
服务器。因此,正如我所建议的,使用流程管理器启动cron:或者您可以直接转到hacky root并在后台启动cron。(要在后台启动cron,只需在行的末尾添加一个&即可)
SHELL=/usr/bin/zsh
* * * * * echo $PATH >> /root//reboot_record.txt >> /tmp/cron_debug_log.log 2>&1
* * * * * cd /home/poc/lazy-bird/j && ruby j.rb >> /tmp/cron_debug_log.log 2>&1
* * * * * echo $PATH >> /root//reboot_record.txt >> /tmp/cron_debug_log.log 2>&1
* * * * * cd /home/poc/lazy-bird/p && ruby p.rb >> /tmp/cron_debug_log.log 2>&1
#====================================
# Scripts to run cron job
#====================================
# Add crontab file in the cron directory
ADD cron_lazy_bird /etc/crontab
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Use the crontab file
RUN crontab /etc/crontab
# Run the command on container startup
#CMD cron  && tail -f /var/log/cron.log
#====================================
# Scripts to run Selenium Standalone
#====================================
COPY entry_point.sh /opt/bin/entry_point.sh
RUN chmod +x /opt/bin/entry_point.sh
USER seluser
EXPOSE 4444
USER root
CMD ["/bin/bash", "/opt/bin/entry_point.sh"]
cron  && tail -f /var/log/cron.log

export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" \
    java -jar /opt/selenium/selenium-server-standalone.jar \
    -role node \
    -hub http://$HUB_1_PORT_4444_TCP_ADDR:$HUB_1_PORT_4444_TCP_PORT/grid/register \
    -browser browserName=firefox