Quick Guide for Datadog Agent on Docker for Logs
This guide explains how to configure the Datadog Agent within Docker containers to collect application and container logs. It covers basic setup using environment variables and describes how to extend log collection to additional services by mounting their log directories.
-
Use the official Datadog Agent image with Docker’s environment variables to ensure that you collect all logs from the containers.
docker run -d --name datadog-agent -e DD_API_KEY=kloudfuse -e DD_SITE=https://<kf-domain-name>/ingester -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true -e DD_LOGS_ENABLED=true -e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true -e DD_APM_ENABLED=true -e DD_DD_URL=https://<kf-domain-name>/ingester --volume /var/run/docker.sock:/var/run/docker.sock:ro --volume /proc:/host/proc:ro --volume /sys:/host/sys:ro --volume /host:/host:ro --name datadog-agent datadog/agent:latest -
Expose Docker container logs through its Docker Logs system, and run the Docker Agent with log forwarding configuration:
docker run -d --name nginx -v /path/to/nginx/logs:/var/log/nginx nginx -
To collect logs for additional services, such as Nginex, mount its log directory.