Monitor docker not connecting to docker

Has anyone got any experience of getting Monitor Docker working once added via HACS?

I have followed the instructions, added docker.sock added as a volume in the docker compose file. I have tried enabling the docker API for remote connections and specifying the IP in the config file but no matter what I do the logs show that the integration cant connect to the docker API.

Any suggestions on where to start?

HA core 2022.10.2 running in docker on ubuntu
Docker version 20.10.12
Docker-compose version 1.25.0

Error message:
[Docker]: Can not connect to Docker API (Missing valid docker_host.Either DOCKER_HOST or local sockets are not available.)

Docker compose file:

    container_name: hass
    image: homeassistant/home-assistant
      - /home/user/docker-configs/ha:/config
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      #Allow docker connections from within container
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
      - mosquitto
      #Zigbee USB controller
      - "/dev/ttyACM0:/dev/ttyACM0"

HA config:

name: Docker
#url: unix:///var/run/docker.sock #Tested to see if it would work - No
#url: tcp:// #Tested to see if would work - No
 - homeassistant
 - pihole
 - nut
 - unifi
 - version
 - containers_running
 - containers_total
 - state
 - status
 - memory
 - uptime
 - memory_percentage

I haven’t used it but it looks like you are missing a line in configuration.yaml

  - name: Docker
      - appdaemon

configuration.yaml file is:

#Extra config files
monitor_docker: !include docker.yaml

and docker.yaml which I think is correct:

name: Docker
#url: unix:///var/run/docker.sock
#url: tcp://
  - homeassistant
  - pihole
  - nut
  - unifi

As a test, I tried adding ti all directly to the configuration.yaml file and get the same result. monitor_docker is running but cant connect to the docker instance its running in.

Connecting to the docker API via curl works from the host running docker so that side seems to be ok

1 Like
logger:   ####  Need to view full HA core logs and can be filtered 
  default: info
     custom_components.monitor_docker: debug

shows up in my log , not seeing any sensors though.

I already have debug enabled and getting this error in the log

2022-10-31 12:48:59.383 DEBUG (Thread-2 (RunDocker)) [custom_components.monitor_docker.helpers] [Docker]: Helper version: 1.14
2022-10-31 12:48:59.386 ERROR (Thread-2 (RunDocker)) [custom_components.monitor_docker.helpers] [Docker]: Can not connect to Docker API (Missing valid docker_host.Either DOCKER_HOST or local sockets are not available.)
  File "/config/custom_components/monitor_docker/", line 162, in __init__

Its all very strange :slight_smile:

No matter how I try to get it to connect, socket or via api on port 2376, it just doesnt want to connect so I am guessing its a container or docker config issue but can’t for the life of me find anything that looks wrong

did you do this part?
I didn’t check my logs before I did that.

Raspberry Pi (Raspbian)

Using a Raspberry Pi with Raspbian it could happen no memory is reported. In such case the Docker API does not report it to Monitor Docker. Making the following changes, normally fixes the problem:

Open the file /boot/cmdline.txt
Add the following to the end of the existing line cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
Reboot your Raspberry Pi
NOTE: Add the line to the existing line, do not replace it

Ubuntu / Debian

Also on Ubuntu/Debian it is possible no memory is shown, the following changes could solve your problem:

Open the file /etc/default/grub
Modify the GRUB_CMDLINE_LINUX_DEFAULT="" to GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"
Run sudo update-grub
Reboot your Ubuntu/Debian
NOTE: This is untested, use at your risk

I havent modified the grub config as yet as I dont have anything so not seeing memory isnt a concern at the moment :slight_smile:

well I put the grub back to “quiet”
update-grub and did a reboot.
Still works after that

no real difference between my container setup.
except perhaps the privileged: true

    container_name: homeassistant
    image: ""
      - /usr/share/hassio/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped
    privileged: true
    network_mode: host
      - mosquitto

I just updated the container to 2022.10.5 and it now works :sob:

I hate it when I cant figure out why it doesn’t work!

Oh well, time to build some dashboards

1 Like