Docker logging

From wikieduonline
Jump to navigation Jump to search

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": {}

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 for more information

Related terms

See also

  • Advertising: