docker logs

Command Name: 

docker logs

Description:

This command will fetch the logs of the running or exited container.

This command is useful when you want to check what is happening inside the container. For this you need to print the logs else logs will not be fetched. If you are running any application then you can see the logs of that application using this command.

Syntax:

easywhatis$ docker logs --help

Usage: docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

Options:
      --details        Show extra details provided to logs
  -f, --follow         Follow log output
      --since string   Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
      --tail string    Number of lines to show from the end of the logs (default "all")
  -t, --timestamps     Show timestamps
      --until string   Show logs before a timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
easywhatis$

Example:

easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                        PORTS               NAMES
a5bb226d1850        ubuntu              "bash"              7 hours ago         Exited (137) 23 minutes ago                       eloquent_knuth
easywhatis$ docker logs a5bb226d1850
root@a5bb226d1850:/# exit


exit
root@a5bb226d1850:/# easywhatis$