'How to easily debug Redis and Django/Gunicorn when developing using Docker?

I'm not referring to more sophisticated debugging techniques, but how to get access to the same kind of error messages that are normally directed to terminal tabs? Basically I'm adopting Docker in a Django project also using Redis.

In the old way of working I opened a linux terminal tab for gunicorn like this: gunicorn --reload --bind 0.0.0.0:8001 myapp.wsgi:application

And this tab kept running Gunicorn and any Python error was shown in this tab so I could see the problem and fix it.

I could also open a second tab for the celery woker: celery -A myapp worker --pool=solo -l info

The same thing happened, the tab was occupied by Celery and any Python error in a task was shown in the tab and I could see the problem and correct the code.

My question is: Using docker is there a way to make each of the containers direct these same errors that would previously go to the screen, to go to log files so that I can debug my code when an error occurs in Python?

What is the correct way to handle simple debugging during development using Docker containers?



Solution 1:[1]

After looking more about this in the docker documentation I found a link that solves this problem: View logs for a container or service

Basically the command "docker logs CONTAINER_ID" shows on the screen exactly what we would see in the terminal running the application.

Works perfectly to see Django, Redis and Angular logs.

Just type:

docker logs CONTAINER_ID

Replace the container_id keyword with the real id of the container you want to log in.

To find the id type:

docker ps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pity Maia