Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View logs for all docker containers simultaneously

I currently use docker for my backend, and when I first start them up with

docker-compose up 

I get log outputs of all 4 dockers at once, so I can see how they are interacting with each other when a request comes in. Looking like this, one request going from nginx to couchdb

http://i.imgur.com/E4GQ43F.png

The issue is now that I am running on GCE with load balancing, when a new VM spins up, it auto starts the dockers and runs normally, I would like to be able to access a load balanced VM and view the live logs, but I can not get docker to allow me this style, when I use logs, it gives me normal all white font with no label of where it came from.

Using

docker events   

does nothing, it won't return any info.

tldr; what is the best way to obtain a view, same as the log output you get when running "docker-compose up"

like image 903
Anthony Taylor Avatar asked Apr 20 '16 23:04

Anthony Taylor


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.

Can I access the logs of the docker 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.

How do I monitor logs from a docker container?

Viewing Container Logs You can use docker ps -a to get the IDs and names of your containers. The logs command prints the container's entire log output to your terminal. The output will not be continuous. If you'd like to keep streaming new logs, add the --follow flag to the command.


1 Answers

If using docker-compose, you use

docker-compose logs --tail=0 --follow 

instead of

docker logs --tail=0 --follow 

This will get the output I was originally looking for.

like image 76
Anthony Taylor Avatar answered Oct 02 '22 07:10

Anthony Taylor