Home >Operation and Maintenance >Docker >Where are docker logs stored?
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.
The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.
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!