Ad Widget

Collapse

dial unix /var/run/docker.sock: connect: permission denied

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheMaxxz
    Junior Member
    • Aug 2020
    • 2

    #1

    dial unix /var/run/docker.sock: connect: permission denied

    Hi,

    I'm experimenting with zabbix and have deployed & configured following 3 docker images:
    zabbix/zabbix-agent2:alpine-trunk (https://hub.docker.com/r/zabbix/zabbix-agent2)
    zabbix/zabbix-appliance:alpine-trunk
    zabbix/zabbix-snmptraps:alpine-trunk

    Everything appears to be working except for monitoring docker.

    When doing following in the zabbix-apliance

    /var/lib/zabbix # zabbix_get -s zabbix-agent -k docker.info
    ZBX_NOTSUPPORTED: Cannot fetch data.

    I get following in the zabbix agent2 logs.
    2020/08/01 12:03:32.518017 [Docker] cannot fetch data: Get http://1.28/info: dial unix /var/run/docker.sock: connect: permission denied

    My zabbix-agent2 docker was created as follows:

    # Start Zabbix agent 2
    docker run -d \
    --network "zabbix-net" \
    --name zabbix-agent \
    -v "/root/docker/zabbix/mounts/agent/etc-zabbix_agentd.d/:/etc/zabbix/zabbix_agentd.d/" \
    -v "/root/docker/zabbix/mounts/agent/var_lib_modules/:/var/lib/zabbix/modules/" \
    -v "/root/docker/zabbix/mounts/agent/var_lib_enc/:/var/lib/zabbix/enc/" \
    -v "/var/run/docker.sock:/var/run/docker.sock" \
    --privileged \
    -e ZBX_HOSTNAME="Zabbix server" \
    -e ZBX_SERVER_HOST="zabbix-appliance" \
    -e ZBX_PASSIVESERVERS="zabbix-appliance" \
    -e ZBX_ENABLEREMOTECOMMANDS="1" \
    -e ZBX_DEBUGLEVEL="5" \
    zabbix/zabbix-agent2:alpine-trunk

    I even went as far as adding the 'zabbix' user to the docker group on the docker host itself, which I don't believe should be needed, but it's still not working.

    My docker version is: Server Version: 19.03.12

    Thanks for any insight on this.
  • TheMaxxz
    Junior Member
    • Aug 2020
    • 2

    #2
    Ok I managed to make it work by modifying the agent container with '--exec --user root' and changing the /etc/group file.
    I add a new docker group that matches the docker group on the docker host and added the zabbix to this group.
    A quick restart of the agent container and it's working.

    Comment

    • jdesai61
      Junior Member
      • Oct 2020
      • 1

      #3
      Thanks. Attaching the /var/run/docker.sock was the piece I was missing...

      Comment

      Working...