Viewing logs

Most applications output their log entries to the standard stdout stream. If the container is being run in the foreground mode, you will just see it in the console. However, when running a container in detached mode, you will see nothing but the container ID on the console. However, the Docker engine collects all the stdout output from a running container in a history file on the host. You can display it by using the docker logs command. The syntax of the command is as follows:

$ docker logs -f <container name or ID>  

The docker logs command will output just a few last lines of the log into the console. As the container still works in the background (in detached mode), you will be given the prompt back immediately, as you can ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.