Skip to content
Download

Send OpenTelemetry from Docker Compose to your Mac

Your app already sends OpenTelemetry, and now it runs in a container. One address changes.

Inside a container, 127.0.0.1 is the container. The Mac is host.docker.internal, which Docker Desktop and OrbStack both provide.

compose.yaml
services:
api:
build: .
environment:
OTEL_SERVICE_NAME: my-api
OTEL_EXPORTER_OTLP_ENDPOINT: http://host.docker.internal:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf

Confirm the port first. Open Collectors → Loggerhead receiver → Connection and copy the HTTP port. A Docker port forward often holds 4318 itself, and the receiver then moves along the ladder to 14318. See Ports and the effective port.

Set the shared variables once and let every service read them:

compose.yaml
x-otel: &otel
OTEL_EXPORTER_OTLP_ENDPOINT: http://host.docker.internal:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
services:
api:
environment:
<<: *otel
OTEL_SERVICE_NAME: api
worker:
environment:
<<: *otel
OTEL_SERVICE_NAME: worker

Each service keeps its own OTEL_SERVICE_NAME, so Loggerhead colours them apart.

A record with no tag lands in the Local environment. To send a deployment somewhere else, name an environment that the workspace has:

OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=staging

See Workspaces and environments.

A branch collector in the same Compose file gives you one place to drop noisy records and one identity for the whole stack. The app then points at the branch instead of the Mac. See Docker branch example.

  1. Run docker compose up and call one endpoint. Open Logs in Loggerhead.
  2. Connect your coding agent once, and it reads the same data. See Claude Code.