Running a python program with cron, Docker and Supervisor
<p>When I run build the container with the CMD as <code>CMD /usr/bin/python3 /app/test.py</code>  everything runs fine and I see an output, but when I run the CMD as <code>CMD ["/usr/bin/supervisord", "-n"]</code> which runs supervisor and cron, I see not output.  It seems like the python file is not running, or i'm not properly setup to see logging.</p>

<p>How can I ensure the python file is running and how can I see the output?</p>

<p>My Dockerfile is:</p>

<pre><code>FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y apt-utils -y cron -y liblapack3 -y build-essential \
                    -y python3-dev -y python3-setuptools -y python3-numpy \
                    -y python3-scipy -y python3-pip -y libatlas-dev \
                    -y supervisor


COPY . /app

# install requirements (early and on their own to leverage caching)
COPY ./requirements.txt /app/requirements.txt
RUN pip3 install -r /app/requirements.txt

# make script executable
RUN chmod +x /app/test.py

# do cron stuff
COPY ./crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab

CMD cron &amp;&amp; tail -f /var/log/cron.log


COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# CMD ["/usr/bin/supervisord", "-n"]
CMD /usr/bin/python3 /app/test.py
</code></pre>

<p>supervisord.conf is:</p>

<pre><code>[supervisord]
nodaemon=true
loglevel=debug

[program:cron]
command = cron -f -L 15
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
</code></pre>

<p>crontab is:</p>

<pre><code>* * * * * root /usr/bin/python3 /app/test.py
* * * * * root echo "hello world" &gt;&gt; /var/log/cron.log 2&gt;&amp;1
</code></pre>

<p>and test.py is:</p>

<pre><code>#!/usr/bin/env python
import logging

from lib.rig import settings

#set logging level to INFO
logging.getLogger().setLevel(settings.get('logging_level'))

logging.info('LOLOLOL')
print('this is a print')
</code></pre>

<p>You're missing the <code>PATH</code> environment variable declaration, which is causing your Python app to not run. Editing your Dockerfile to the following should fix the issue for you:</p>

<pre><code>FROM ubuntu:16.04

ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# This is the line that matters ^^

RUN apt-get update
...
</code></pre>

<p>See more on the <code>ENV</code> variable <a class='doc-link' href="http://stackoverflow.com/documentation/docker/3161/dockerfile/11006/env-directive#t=201610181215353951059">here</a>.</p>

python docker cron supervisord