- create a minimal collector configuration that listens for OTLP (gRPC and HTTP),
- write a
docker-compose.yamlthat mounts the config into the container and forwards host ports, - start the collector with
docker compose up.
- OpenTelemetry Collector docs: https://opentelemetry.io/docs/collector/
- otel/opentelemetry-collector Docker Hub: https://hub.docker.com/r/otel/opentelemetry-collector
- otel/opentelemetry-collector-contrib Docker Hub: https://hub.docker.com/r/otel/opentelemetry-collector-contrib
1) Minimal collector configuration
Save the following asotel-collector-config.yaml. This config enables the OTLP receiver (gRPC and HTTP) and a debug exporter for traces, metrics, and logs.
4317 for OTLP/gRPC and 4318 for OTLP/HTTP. When running in Docker, these container ports must be published to the host.
2) Choose an image
You can pick either the core or contrib image from Docker Hub:- Core:
otel/opentelemetry-collector— a minimal set of components. - Contrib:
otel/opentelemetry-collector-contrib— includes many additional receivers, exporters and processors.
3) docker-compose.yaml
Create adocker-compose.yaml next to your otel-collector-config.yaml. This example:
- uses the contrib image,
- mounts the local config into the container at the collector’s default path,
- exposes ports
4317and4318, - sets a readable container name.
docker-compose.yaml:
Mount path and —config flag
If you mount the config file to a non-default path inside the container, pass the
--config flag via the command: field in your compose file. In the example above we mount to /etc/otelcol/config.yaml, which is the collector’s default config path, so no command: is necessary.4) Start the collector
From the directory containing both files:Quick reference
| Item | Description | Example / Command |
|---|---|---|
| Config file | Collector config enabling OTLP receiver and debug exporter | otel-collector-config.yaml (see above) |
| Collector image | Choose core or contrib from Docker Hub | otel/opentelemetry-collector-contrib:0.135.0 |
| Ports | Host-to-container forwarding for OTLP | 4317:4317 (gRPC), 4318:4318 (HTTP) |
| Start command | Bring container up with Compose | docker compose up |
Troubleshooting
If you see an error about a conflicting container name (for example: “Conflict. The container name “/otel-collector” is already in use…”), either remove or rename the existing container before reusing that name:
- Remove:
docker rm -f otel-collector - Or choose a different
container_namein the compose file.