Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to mount docker.sock?

Edited

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://%2Fvar%2Frun%2Fdocker.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://%2Fvar%2Frun%2Fdocker.sock/v1.21/containers/json?filters=%7B%22status%22%3A%5B%22running%22%5D%7D&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?

1 answer

+1 also facing this issue, which is kinda blocking me from running E2E tests properly.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,516 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you