arrow_back
Back

Docker logs: docker logs, drivers, and events

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Unless you configure logging differently, Docker captures container output on STDOUT and STDERR. Read it with docker logs.

Follow logs from a running container:

docker logs -f <container>

Docker Remote API

Example using TLS client certificates:

curl -i --cacert ~/.docker/machine/certs/ca.pem \
    --cert ~/.docker/machine/certs/ca.pem \
    --key ~/.docker/machine/certs/key.pem \
    "https://$(docker-machine ip default):2376/containers/\
    $(docker ps -lq)/logs?stderr=1&stdout=1"

Log drivers

Set the driver with --log-driver on docker run:

  • json-file — default; writes JSON log files on the host.
  • syslog — send logs to syslog.
  • journald — systemd journal.
  • gelf — Graylog Extended Log Format.
  • fluentd — forward to open_in_new fluentd .
  • none — disable logging.

ELK stack

ELK — Elasticsearch, Logstash, and Kibana:

Docker events API

Docker emits events for most container lifecycle steps: create, destroy, die, export, kill, pause, attach, restart, start, stop, unpause.

  • die — container process exited.
  • destroy — container removed (docker rm).

Watch events:

docker events
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Docker images: layers, UnionFS, and storage drivers

arrow_forward