Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print timestamps in Docker Compose logs

I am seeing my web logs with docker-compose logs web, but I would like to add timestamps to those messages, because now they're quite out of context (don't know when did the event happen). I tried docker-compose logs -t web, but it seems Docker Compose is unaware of this flag.

Do you have any idea how can I make timestamps appear in Docker Compose logs?

like image 938
linkyndy Avatar asked May 02 '15 14:05

linkyndy


People also ask

How do I check my docker pull logs?

Docker has a dedicated command which lists container logs. The docker logs command. The flow will usually involve you checking your running containers with docker ps, then check the logs by using a container's ID. This command will list all logs for the specified container.

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 can I see live logs of a container?

You can run the container in foreground mode so you will able to see log. -it keep the container running in foreground as a result you will able to see your container logs. You will able to see live logs same like running application in terminal.


2 Answers

docker-compose version 1.8.0 supports logs, you can use:

docker-compose logs -t
like image 153
Ittiel Avatar answered Sep 28 '22 08:09

Ittiel


docker-compose now supports the -t argument, as pointed out by Ittiel.

like image 38
Adrian Mouat Avatar answered Sep 28 '22 07:09

Adrian Mouat