Discovery.docker not working with Linux installation, only with Alloy running in Docker as well

I installed Grafana Alloy on my linux server following this guide Install Grafana Alloy on Linux | Grafana Alloy documentation

This is my config file in /etc/alloy/config.alloy

discovery.docker "linux" {
  host = "unix:///var/run/docker.sock"
}

I have some docker containers running on the same server but they are not being discovered when I look in the livedebugging UI (see exports.targets is empty).

However when I run Alloy also via Docker (instead of the normal Linux installation) - with the exact same config file - the containers now show up and everything works as expected.

services:
  alloy:
    image: grafana/alloy
    ports:
      - 12344:12345
      - 4317:4317
      - 4318:4318
    volumes:
      - /etc/alloy/config.alloy:/etc/alloy/config.alloy
      - /var/run/docker.sock:/var/run/docker.sock
    command: run --server.http.listen-addr=0.0.0.0:12345 --storage.path=/var/lib/alloy/data /etc/alloy/config.alloy

Is this expected behaviour? I can’t find any info on this in the documentation.

  1. Check and see if the grafana user is in the docker group, or you can run alloy with root user.
  2. Check which container engine you are using (for example recent rocky and redhat aren’t using docker by default any more).