问题原文
原帖链接 · TomFirth · CC BY-SA 3.0
My Dockerfile appears to build correctly (it tells me so). When I run the container, I get the below error message. I have tried running the commands (CMD) with and without the service's directory.
crontab.sh basically writes a cron schedule to a text file (cron.jobs) and then imports the text file to crontab.
Dockerfile:
FROM node:0.10
MAINTAINER Tom
VOLUME /var/log/
RUN mkdir /pulse
ADD . /pulse
WORKDIR /pulse
RUN apt-get update && apt-get install -y cron
ADD *.sh /pulse/
RUN chmod 750 /pulse/crontab.sh && chmod 750 /pulse/
RUN chmod 644 /etc/crontab
CMD cron -f
CMD touch /var/log/cron.log && sh /pulse/crontab.sh && tail -f /var/log/cron.log
CMD cron /pulse/cron.jobs
CMD crontab -l
edited to add crontab.sh
crontab.sh (some crons have been removed):
#!/bin/bash
cat <<- 'EOF' > cron.jobs
0 * * * * node /pulse/scripts/awsPulseTest.js > /tmp/awsPulseTest.log 2>&1
EOF
crontab cron.jobs
Error:
no crontab for root
Side notes:
- Pulse is the name of the service.
- The version of node is old due to the service, this will be upgraded.
- The service is essentially for cron jobs in node
已采纳解答
原帖链接 · Paul Haldane · CC BY-SA 3.0
It's an issue with the dockerfile (rather than the commands in the file).
Only one CMD is run (the last one) - see https://docs.docker.com/engine/reference/builder/#cmd
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
