我只是想在Docker容器中运行Django管理命令作为cron。
Dockerfile:
FROM python:3
MAINTAINER DAWN
ENV PYTHONUNBUFFERED 1
RUN apt-get update
RUN apt-get install -y vim
RUN apt-get install -y nginx
RUN apt-get install -y gdal-bin
RUN apt-get -y install cron
RUN mkdir /code
WORKDIR /code
RUN mkdir /code/logs
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD ./my_project /code
COPY ./docker-entrypoint.sh /code/my_project/
COPY ./django_nginx.conf /etc/nginx/sites-available/
RUN rm -f /etc/nginx/sites-available/default
RUN ln -s /etc/nginx/sites-available/django_nginx.conf /etc/nginx/sites-enabled
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
ADD crontab /etc/cron.d/my_cron
RUN chmod 0644 /etc/cron.d/my_cron
RUN touch /var/log/cron.log
ENTRYPOINT ["/code/my_project/docker-entrypoint.sh"]
RUN /usr/bin/crontab /etc/cron.d/my_cron
的crontab:
1 * * * * root python /code/manage.py my_management_command >> /var/log/cron.log 2>&1
这个cron没有被执行,即使我可以通过使用
连接容器在容器内的crontab中看到它docker exec -it my_container /bin/bash
crontab -l
我哪里错了?