Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker logs command doesn't show any logs

Tags:

docker

flask

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"]
like image 525
Kitwradr Avatar asked Jan 23 '20 09:01

Kitwradr


People also ask

How do I view all docker logs?

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.

How can we see the logs from a running container?

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.


1 Answers

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
like image 171
sandeep P Avatar answered Sep 18 '22 03:09

sandeep P