Difference between revisions of "Docker logging"
Jump to navigation
Jump to search
↑ https://docs.docker.com/config/containers/logging/configure/
↑ https://docs.docker.com/config/containers/logging/configure/
↑ https://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
(26 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | Docker support logging to format or different platforms, such as | + | Docker support logging to format or different platforms, such as <ref>https://docs.docker.com/config/containers/logging/configure/</ref> |
− | + | * <code>[[json-file]]</code> (default) | |
+ | * <code>[[syslog]]</code> | ||
+ | * <code>[[journald]]</code> | ||
+ | * <code>[[gelf]]</code> | ||
+ | * <code>[[fluentd]]</code> | ||
+ | * <code>[[awslogs]]</code> | ||
+ | * <code>[[splunk]]</code> | ||
+ | * <code>[[etwlogs]]</code> | ||
+ | * <code>[[gcplogs]]</code> | ||
+ | * <code>[[logentries]]</code> <ref>https://docs.docker.com/config/containers/logging/configure/</ref> | ||
+ | |||
+ | |||
+ | Configuration is done at docker container start time with command <code>docker run -it --log-drive LOG_METHOD CONTAINER_ID</code> | ||
+ | |||
+ | Sending logs to [[syslog]] or [[logstash]] | ||
+ | docker run --log-driver=syslog --log-opt syslog-address=tcp://<logstash-system-ip>:5000 hello-world | ||
+ | |||
+ | |||
+ | |||
+ | |||
* Check method configured in a running container: | * Check method configured in a running container: | ||
− | + | <pre> | |
− | + | docker inspect -f '{{.HostConfig.LogConfig.Type}}' CONTAINER_ID | |
+ | docker inspect -f '{{.HostConfig.LogConfig}}' CONTAINER_ID | ||
+ | |||
+ | docker inspect <container_id|container_name> | grep -A 5 LogConfig | ||
+ | |||
+ | "LogConfig": { | ||
+ | "Type": "syslog" | ||
+ | "Config": {} | ||
+ | } | ||
+ | |||
+ | </pre> | ||
* View [[logs]] | * View [[logs]] | ||
:<code>[[docker logs]] CONTAINER_NAME_OR_ID</code> (Docker Community Engine only support: local, json-file and [[journald]]) | :<code>[[docker logs]] CONTAINER_NAME_OR_ID</code> (Docker Community Engine only support: local, json-file and [[journald]]) | ||
Line 9: | Line 38: | ||
:See https://docs.docker.com/config/containers/logging/ for more information | :See https://docs.docker.com/config/containers/logging/ for more information | ||
+ | |||
+ | * <code>[[docker-compose logs]]</code> | ||
+ | |||
+ | == Related terms == | ||
+ | * [[Container logging]] | ||
+ | * <code>[[journalctl -u docker]]</code> | ||
+ | * <code>[[aws logs create-log-group]]</code> | ||
+ | * See also https://stackoverflow.com/questions/30969435/where-is-the-docker-daemon-log/30970134#30970134 for further information about docker logs. | ||
+ | * <code>[[kubectl logs]]</code> | ||
== See also == | == See also == | ||
+ | * {{docker logging}} | ||
* {{Docker}} | * {{Docker}} | ||
+ | * {{logging}} | ||
[[Category:Docker]] | [[Category:Docker]] |
Latest revision as of 15:24, 23 May 2022
Docker support logging to format or different platforms, such as [1]
Configuration is done at docker container start time with command docker run -it --log-drive LOG_METHOD CONTAINER_ID
Sending logs to syslog or logstash
docker run --log-driver=syslog --log-opt syslog-address=tcp://<logstash-system-ip>:5000 hello-world
- Check method configured in a running container:
docker inspect -f '{{.HostConfig.LogConfig.Type}}' CONTAINER_ID docker inspect -f '{{.HostConfig.LogConfig}}' CONTAINER_ID docker inspect <container_id|container_name> | grep -A 5 LogConfig "LogConfig": { "Type": "syslog" "Config": {} }
- View logs
docker logs CONTAINER_NAME_OR_ID
(Docker Community Engine only support: local, json-file and journald)docker logs CONTAINER_NAME_OR_ID
2>&1 | grep "STRING_TO_SEARCH" (You will need to redirect outputs to be able to grep output)[3]- See https://docs.docker.com/config/containers/logging/ for more information
Related terms[edit]
- Container logging
journalctl -u docker
aws logs create-log-group
- See also https://stackoverflow.com/questions/30969435/where-is-the-docker-daemon-log/30970134#30970134 for further information about docker logs.
kubectl logs
See also[edit]
- Container logging, Docker logging:
docker logs
,docker-compose logs
- Docker:
docker-compose
, Docker Desktop, Docker Scout, Docker Swarm, Docker Volumes, Docker images management, docker network,docker inspect
,docker volume inspect
,Dockerfile
, Docker Engine release notes,docker kill
,moby
, Docker-in-Docker,docker context
,buildx
,docker tag
,docker system prune
, Docker Hub,hub-tool, /etc/docker/daemon.json
,hostconfig.json
, dockerd, logs, Docker logging, Backup,docker service
,depends on
,--dns, --filter
,--mount
,docker login
,docker build
,apt remove docker.io
,.dockerignore
, docker context ls |docker-machine, .docker/
, PWD,$HOME/.docker/config.json
, Docker ID,--env-file, docker --help
- Linux logging, Cisco IOS logging
Advertising: