Home >Operation and Maintenance >Docker >Where are docker logs stored?

Where are docker logs stored?

WBOY
WBOYOriginal
2022-03-08 15:45:5016514browse

Docker’s logs are stored in files ending with “json.log” in “/var/lib/docker/containers/ID/ID-json.log”; you can use the built-in command “docker logs -f e4bd48ef3103" to view the log.

Where are docker logs stored?

The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.

Where are docker’s logs stored?

Docker stores container logs in its primary storage location /var/lib/docker/. Each container has an ID specific to it. The logs (full ID, not the shortened ID usually shown), you can access it like this:

/var/lib/docker/containers/ID/ID-json.log

This is where they are stored, but since they are in JSON format they are not easy to read, and Having to use the full container ID is annoying. Docker provides a built-in command to view them:

docker logs -f e4bd48ef3103

Here, the -f flag will keep the prompt open and "watch" for any new entries in the file. You can also use --tail the file, or --timestamps to display log times, or --until and --since to filter based on time.

If you use Docker Compose, you can easily view all the logs using the log command there:

docker-compose  logs

However, one thing you will notice is that STDOUT and STDERR are important for a lot of things are all useful, but only show console output for the entry point specified by "CMD" in the Docker file. Many applications have their own dedicated logging systems, which typically log to /var/log/nginx/access.log. Such logs can still be accessed from the host side via Docker.

Recommended learning: "docker video tutorial"

The above is the detailed content of Where are docker logs stored?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn