Collector docker image custom config
denny6389 opened this issue · comments
Describe the question
Is there any way to make a custom config file for Opentelemetry collector docker image? I just need a specific receiver and exporter but the default one has too many resources.
Thank you in advance.
@denny6389 It should be possible to build an image as described in Using a Locally Built Image.
@denny6389, you can mount your config file at /etc/otel-collector.yaml to override the default one.
Looking at Dockerfile, you might need to mount it to /etc/otel/config.yaml
I will give it a try. Thank you!!
@hickeyma, @denny6389
Ah, I realized I had passed the path of the config file to the container too:
docker-compose.yml:
version: "3.9"
services:
otel-collector:
image: otel/opentelemetry-collector:0.52.0
command: [ "--config=/etc/otel-collector.yaml" ]
volumes:
- ./otel-collector.yml:/etc/otel-collector.yaml
We use AWS ECR to keep local images, using a simple bash script:
docker build --build-arg OTEL_VERSION=$OTEL_VERSION -t tools/opentelemetry-collector:$OTEL_VERSION .
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin $ECR
docker tag tools/opentelemetry-collector:$OTEL_VERSION $ECR/tools/opentelemetry-collector:$OTEL_VERSION
docker push $ECR/tools/opentelemetry-collector:$OTEL_VERSION
The Dockerfile
ARG OTEL_VERSION
FROM otel/opentelemetry-collector:${OTEL_VERSION}
COPY config.yaml /etc/otel-agent-config.yaml
COPY certs/ca.crt /etc/ca.crt
COPY certs/client.pem /etc/client.pem
COPY certs/client.key /etc/client.key
CMD ["--config=/etc/otel-agent-config.yaml"]