Where are logs of docker nginx conainter stored in host
Asked Answered
S

1

3

I use default nginx image and Filebeat to read logs and send them to ELK. Both containers (nginx container and Filebeat container) are on the same host machone.

Here is Dockerfile for nginx image

FROM nginx
COPY . /usr/share/nginx/html/
EXPOSE 80

In my nginx container access log goes to STDOUT and error log goes to STDERR.

When I prompt from host machine docker logs <nginx-containter-id> I can see logs from nginx container. But there is nothing in container's folder on host machine (/var/lib/docker/containers/nginx-container-id)

how can set up filebeat to read logs?

Sudatory answered 11/12, 2018 at 12:59 Comment(0)
U
5

Each container has it's own logfile, you can know where it is by using:

docker inspect --format='{{.LogPath}}' <nginx-containter-id>

It will tell you the path to the logfile.

Referencies:

Ungraceful answered 11/12, 2018 at 13:16 Comment(2)
I'm afraid there must be something it is not well understood or there are some gap since this command promts the path of the logfile that stores all the output from the container since it was started. It may be a silly question but have you properly set the container id that corresponds to the container?. If nothing is shown it may be because the docker log system is setted to none like: docker run -it --log-driver none <DOCKER_IMAGE>Ungraceful
Thank you, @Ungraceful ! Your last comment and links you provided were helpful. After running container with logging argument, the command shows me the pathSudatory

© 2022 - 2024 — McMap. All rights reserved.