Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use --since option with docker logs command

I want to look at last 1 hour of docker container log using docker logs --since option. Which value I should provide for --since parameter?

like image 929
kgs Avatar asked Jun 08 '17 18:06

kgs


People also ask

What is the docker command for container logs?

Docker Command for Checking Container Logs To find the container ID, use the docker ps command to list running containers. As in the image below, Docker responds by listing the event logs for that specific container in the output.

How do I access docker logs?

Using Default Log File By default, Docker stores log files in a dedicated directory on the host using the json-file log driver. The log file directory is /var/lib/docker/containers/<container_id> on the host where the container is running.

How do I get docker logs for a specific date?

To view logs until a specific date, use the “–until” option with a date or a duration. You can also provide a date format like you did before for the since option.


2 Answers

as the help says

--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes

I would do

docker logs mycontainer_or_id --since 60m

This syntax is correct according to my active container

like image 183
user2915097 Avatar answered Oct 08 '22 19:10

user2915097


Please refer to the Docker docs.

docker logs --since 1h

The --since option shows only the container logs generated after a given date. You can specify the date as an RFC 3339 date, a UNIX timestamp, or a Go duration string (e.g. 1m30s, 3h). Besides RFC3339 date format you may also use RFC3339Nano, 2006-01-02T15:04:05, 2006-01-02T15:04:05.999999999, 2006-01-02Z07:00, and 2006-01-02.

like image 40
hackjutsu Avatar answered Oct 08 '22 17:10

hackjutsu