On a Raspberry Pi 2, I used the image resin/rpi-raspbian:stretch
for running a Django application. In my Dockerfile, I Install the python3
package and start the application using ENTRYPOINT python3 manage.py runserver 0:8000
. This works, BUT when my code throws error, I got NO output using docker log
command.
Example
I have a ImportError. When I run the command manually using docker exec
, I got the exception as expected:
pi@pi2:/etc/docker/container/pms $ sudo docker exec -it pms_app_1 python3 manage.py runserver 0:8000
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x75de3228>
[...]
ImportError: No module named 'ws4redisfrontend'
But when I run the container using docker-compose
and then open the logs, they're empty:
pi@pi2:/myapp $ sudo docker logs myapp_1
pi@pi2:/myapp $
This behaviour is only present for the manage.py
call. For example, when I extend the entrypoint like this:
ENTRYPOINT python3 -c "print('printed by python inline script')" && python3 manage.py runserver 0:8000
I see printed by python inline script in the container-logs. As a newbie in Python/Django, I can't understand why this happens. But as my print example works, it seems a Django issue, and no general problem of Python. What am I missing? Debug mode is activated in settings.py
.