Got permission denied while trying to connect to the Docker daemon socket

When we first started using the v2 & telegraf input plugins, there was no problem, but restarting the system suddenly the getting this error ([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) and now the InfluxDB 2.0 OSS Metrics & Docker data dashboards are not working… In the database we can see the respective tables are created but they are all empty.

How can we solve this error? Do the system need internet connection for these to work?

Hi @Aritra666B,
Can you trying running:

sudo usermod -aG docker telegraf

Then restart the telegraf service?

Hi @Jay_Clifford ,

I tried it but didn’t work. In the given command I only replaced telegraf with my user.

still get this.
[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

Hi @Aritra666B,
Telegraf generates its own user. You need to add Telegraf to the docker group. Please run the above command again as intended :slight_smile:.

Hi @Jay_Clifford ,

If I run that command it gives me error → usermod: user ‘telegraf’ does not exist.

Do I have to create any group at first with name ‘telegraf’ ?