Public documentation
Documentation indexRead as MarkdownDocker and Compose
Run the Collector on a private container network and instrument each application using its language guide. The Collector receives telemetry; it does not add instrumentation to an unmodified image.
Run the application telemetry Collector
Save compose.yaml and the base Collector configuration in one working directory, naming the latter collector.yaml. The example uses Docker Compose v2 and Collector Contrib 0.160.0.
Load the Corridora endpoint and key, then validate and start:
docker compose config --quiet
docker compose run --rm collector validate --config=/etc/otelcol-contrib/config.yaml
docker compose up -d collector
docker compose logs --tail 100 collector
Host-published receiver ports bind to loopback. Containers on the same Compose network reach the Collector by its service name. The container listens on its internal interfaces, so network membership is part of the receiver's access boundary.
Connect an application container
Add the following settings to an application service on that same network. This is a Compose fragment: merge it with your real image, command, and other environment settings.
services:
app:
environment:
OTEL_SERVICE_NAME: checkout-api
OTEL_RESOURCE_ATTRIBUTES: service.namespace=commerce,deployment.environment.name=staging
OTEL_EXPORTER_OTLP_ENDPOINT: http://collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
Initialize the SDK inside the image using the language guide. Use collector, not localhost, from a separate container. Applications running directly on the Docker host use http://127.0.0.1:4318. Docker port mappings do not change the protocol: 4318 is HTTP and 4317 is gRPC.
Set a distinct service name for each application; do not identify every container as collector. Container IDs are useful instance metadata, not stable service names.
Optional Docker Engine metrics
The Contrib docker_stats receiver queries Docker's statistics API. In 0.160.0, its metrics are upstream alpha and its supported target here is Linux Docker Engine. Application traces and Docker metrics use independent collection paths.
Save docker-stats.yaml beside your Compose file. The standalone metrics Collector needs access to the engine socket. Read-only mounting of a Unix socket does not make the Docker API read-only; authorize that access only for a trusted Collector instance.
On the Linux Docker host, load the same endpoint and key variables, then run:
export CORRIDORA_HOST_NAME="$(hostname)"
export CORRIDORA_HOST_ID="$(cat /etc/machine-id)"
export CORRIDORA_SERVICE_NAMESPACE=commerce
export CORRIDORA_DEPLOYMENT_ENVIRONMENT=staging
docker_socket_gid="$(stat -c '%g' /var/run/docker.sock)"
docker run -d --name corridora-docker-metrics \
--memory=256m --group-add "$docker_socket_gid" \
-e GOMEMLIMIT=160MiB \
-e CORRIDORA_HOST_NAME -e CORRIDORA_OTLP_ENDPOINT -e CORRIDORA_INGEST_KEY \
-e CORRIDORA_HOST_ID -e CORRIDORA_SERVICE_NAMESPACE -e CORRIDORA_DEPLOYMENT_ENVIRONMENT \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v "$PWD/docker-stats.yaml:/etc/otelcol-contrib/config.yaml:ro" \
otel/opentelemetry-collector-contrib:0.160.0 \
--config=/etc/otelcol-contrib/config.yaml
The instance exposes no telemetry receiver port. For rootless Docker, use the engine's actual socket path and permissions. This command is for Linux, not a native macOS Docker socket. A Linux Collector inside Docker Desktop observes the engine's containers, not the macOS host as though it were Linux.
Set a unique, stable CORRIDORA_HOST_ID for each engine host. Check that cloned
hosts have distinct machine IDs, and use the same host ID as the native host
collector if you want a recorded host relationship. The recipe copies the two
Compose project/service labels into resource metadata and enables the Engine's
reported restart count. A Compose service can have several different container
IDs over the investigation interval.
Optional recorded lifecycle events
Use docker-lifecycle.py with Python 3.9 or newer to export Docker Engine events as named OTLP logs. This separate input records create, start, stop, restart, die, OOM, and destroy actions, plus an exit code when the Engine reports one. The resource allowlist includes the full container ID, name, host and deployment scope, and the two Compose labels.
Load the same identity settings as the metrics collector and an ingest key for
the same organization. Include docker-engine in the authorized project if
using a project filter. Run from an approved account with Docker Engine access.
The Python process only reads stdin and exports over HTTPS; Docker access is
required by the CLI. Use a trusted local context or an authorized Engine API
proxy that allows event reads.
set -o pipefail
docker events --filter type=container --filter scope=local \
--filter event=create --filter event=start --filter event=stop \
--filter event=restart --filter event=die --filter event=oom \
--filter event=destroy --format '{{json .}}' \
| python3 docker-lifecycle.py
For a Compose-only stream, add --filter 'label=com.docker.compose.project=your-project'.
Use --dry-run on the Python script to inspect the normalized payload locally.
Keep one event stream per engine and scope. Supervise both processes: the example
exits when export fails and keeps no durable queue or cursor. The Engine's
limited event history cannot guarantee recovery of missed events after an outage.
Read the Docker event documentation
for replay and event-filter behavior.
In a disposable project, restart a test container, then recreate it. Check that
docker.container.lifecycle logs reference the actual container IDs, with the
same Compose project/service labels on the old and replacement instances.
Open the corresponding resource and inspect its lifecycle evidence. An observed
restart and a replacement are separate actions. Use an Engine oom event to
identify observed OOM activity. Check metrics and event coverage separately.
Logs and host metrics
Prefer an application OTLP logging bridge when trace-correlated logs are needed. Collecting container stdout requires a separate supported log path and parser. Do not point a file tailer at Docker's internal files without checking the engine's log driver and rotation format.
For native host metrics and selected application files, use host collection. A container's filesystem and process namespace can describe the container rather than its physical host; choose the collection placement intentionally.
Verify
- Send a fresh sample through the host's published HTTP receiver using Collector verification.
- Exercise a real application route and find its spans under the application's service name.
- If Docker metrics are enabled, wait at least 30 seconds and look for
container.cpu.utilization, container memory metrics, and container identity attributes underdocker-engine. - Inspect both Collector logs for permission errors, endpoint failures, and rejected exports.
- Stop/restart the application and repeat the request to verify instrumentation initializes once.
The examples use bounded in-memory export queues. Restarting a container can lose queued data. See the Collector guide before choosing production buffering and capacity.