I have a flask app in python which is built into an image , when I try to run it using the command
docker logs -f f7e2cd41c0706b7a26d9ff5821aa1d792c685826d1c9707422a2a5dfa2e33796
It is not showing any logs , it should at least show that flask app has started right ? Note that I am able to hit the flask API from the host and it is working.There are many print statements in the code for this API to have worked , so those print statements should have come in the logs. Am I missing something here ?
Dockerfile is :
FROM python:3.6.8
WORKDIR /app
COPY . /app
#RUN apt-get update -y
#RUN apt-get install python-pip -y
RUN pip install -r requirements.txt
EXPOSE 5001
WORKDIR Flask/
RUN chmod -x main.py ;
CMD ["python", "main.py"]
First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.
The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.
you can get logs from your host machine. The default logging driver is a JSON-structured file located on local disk
/var/lib/docker/containers/[container-id]/[container-id]-json. log.
Or the same way as you did will also work.
sudo docker ps -a
sudo docker logs -f container-id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With