Reputation: 878
I use django-crontab in my project. Locally in my project work fine. But I want to use Docker. When I run Docker, I have the following error:
/bin/sh: 1: /usr/bin/crontab: not found
My docker-compose.yml
version: '2.0'
services:
web:
build: .
container_name: test_api
volumes:
- .:/usr/django/app/
expose:
- "8000"
env_file: main.env
command: bash django_run.sh
nginx:
build: ./nginx
container_name: test_ng
ports:
- "8000:8000"
volumes:
- ./nginx/api.conf:/etc/nginx/conf.d/api.conf
- .:/usr/django/app/
depends_on:
- web
links:
- web:web
django_run.sh
#!/usr/bin/env bash
set -e
if [ "$ADD_CRON" == "true" ]; then
python manage.py crontab show
fi
if [ "$ADD_CRON" == "true" ]; then
python manage.py crontab add
fi
if [ "$ADD_CRON" == "true" ]; then
python manage.py crontab show
fi
if [ "$ADD_CRON" == "true" ]; then
python m/usr/local/bin/gunicorn ${DJANGO_APP}.wsgi:application --timeout ${GUNICORN_TIMEOUT} --keep-alive ${GUNICORN_KKEP_ALIVE} -k gevent -w ${GUNICORN_WORKERS} --threads ${GUNICORN_THREADS} -b :${GUNICORN_PORT}
My logs:
test_api | /bin/sh: 1: /usr/bin/crontab: not found
test_api | Currently active jobs in crontab:
test_api | /bin/sh: 1: /usr/bin/crontab: not found
test_api | sh: 1: /usr/bin/crontab: not found
test_api | adding cronjob: (649feb1a8431f09891b644aa4ba2075b) -> ('*/1 * * * *', 'cron.cron_jubs.clear_pdf_files_scheduled_job', '>> /tmp/scheduled_job.log')
test_api | /bin/sh: 1: /usr/bin/crontab: not found
test_api | Currently active jobs in crontab:
test_api | [2018-03-15 14:23:41 +0000] [35] [INFO] Starting gunicorn 19.7.1
Upvotes: 18
Views: 25367
Reputation: 618
Make sure that you already installed cron
with your Dockerfile
It should be something like
RUN apt-get install -y cron
Upvotes: 40