克伦工作在docker工人打破其他前景服务器

为了启动selenium服务器,

我必须在/opt/bin下放入entry_point.sh

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

服务器将不再运行。

我无法弄清楚为什么会被打破

这是我的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 

这是我的docker文件

 #==================================== # 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"] 

更新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 

您的入口脚本需要从ENTRYPOINTCMD指令中调用,否则在启动容器时不会运行。

在启动应用程序之前,您需要删除CMD并从入口点脚本启动cron。 您可能想要使用诸如runit或supervisord之类的进程pipe理器来处理这个问题(请参阅https://docs.docker.com/articles/using_supervisord/ )。