The location of docker's system log is in the "/var/lib/docker/." directory. Each container has a specific log. The specific location is "/var/lib/docker/containers/ ID name/ID name-json.log"; the log is in JSON format, which is difficult to read. You can use a built-in command provided by docker to view it. The syntax is "docker logs -f...".
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
The simple answer is that 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
That's 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 in it:
docker-compose logs
One thing you will notice, however, is that this is STDOUT and STDERR, which Useful for many things, but only displays 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 is the docker system log?. For more information, please follow other related articles on the PHP Chinese website!