Hello,
What I am trying to do.
I want to create a regression test for the service of Telegraf. This can essentially be done by running `telegraf --test`. As we are running this with a docker-compose definition we would like to use this same docker-compose to run the test.
As Telegraf is also collecting docker metrics, we also need to mount the `docker.sock`.
version: '3.7'
services:
telegraf:
image: telegraf:1.18.3-alpine
restart: unless-stopped
environment:
- TELEGRAF_HOSTNAME=${TELEGRAF_HOSTNAME:?}
volumes:
- ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
- /var/run/docker.sock:/var/run/docker.sock
The issue
It seems that Telegraf cannot authenticate against the docker.sock API:
2021-08-11T07:40:12Z E! [inputs.docker] Error in plugin: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http:///var/run/docker.sock/v1.21/info": dial unix /var/run/docker.sock: connect: permission denied
2021-08-11T07:40:12Z E! [inputs.docker] Error in plugin: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http:///var/run/docker.sock/v1.21/containers/json?filters={"status":["running"]}&limit=0": dial unix /var/run/docker.sock: connect: permission denied
What I tried
I do not seem to be able to locate the `/var/run/docker.sock` inside of the pipeline using the following step definitions:
- step:
name: "Test Telegraf config"
services:
- docker
script:
- cd ${BITBUCKET_CLONE_DIR}/telegraf
- TELEGRAF_HOSTNAME=$(hostname) docker-compose run telegraf telegraf --test
How can I use the docker.sock that is required by the services I try to test?