Send OpenTelemetry from Docker Compose to your Mac
Your app already sends OpenTelemetry, and now it runs in a container. One address changes.
The one thing to change
Section titled “The one thing to change”Inside a container, 127.0.0.1 is the container. The Mac is host.docker.internal, which Docker Desktop and OrbStack both provide.
services: api: build: . environment: OTEL_SERVICE_NAME: my-api OTEL_EXPORTER_OTLP_ENDPOINT: http://host.docker.internal:4318 OTEL_EXPORTER_OTLP_PROTOCOL: http/protobufConfirm 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.
Many services at once
Section titled “Many services at once”Set the shared variables once and let every service read them:
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: workerEach service keeps its own OTEL_SERVICE_NAME, so Loggerhead colours them apart.
Tag the environment
Section titled “Tag the environment”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=stagingSee Workspaces and environments.
Or send through one branch collector
Section titled “Or send through one branch collector”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.
Then read it with your agent
Section titled “Then read it with your agent”- Run
docker compose upand call one endpoint. Open Logs in Loggerhead. - Connect your coding agent once, and it reads the same data. See Claude Code.