Exposing docker.sock for monitor_docker

I actually already using this method for almost a couple of months without realizing that I can implement it on the local docker too… And this method is 100% free from error

Hi
How to show all theese sensors
I have only running containers and docker version
I have pasted the code shown on github on config.yaml
Some other way to enable the sensors ?

What is your code in configuration.yaml? Have you set any monitored_conditions?

Thank you for the answer
I’m trying adjusting the code…

Getting this error message

Can not connect to Docker API ([Errno 2] No such file or directory)
Traceback (most recent call last):
  File "/config/custom_components/monitor_docker/helpers.py", line 141, in __init__
    self._api = aiodocker.Docker(url=url)
  File "/usr/local/lib/python3.9/site-packages/aiodocker/docker.py", line 108, in __init__
    ssl_context = self._docker_machine_ssl_context()
  File "/usr/local/lib/python3.9/site-packages/aiodocker/docker.py", line 367, in _docker_machine_ssl_context
    context.load_cert_chain(
FileNotFoundError: [Errno 2] No such file or directory

What have I done wrong? Is it the config/certs or the usr/share/hassio/docker/certs where it cant find the certs?

Used this solution and it works fine

cannot for the life of me get this to work properly! tried the docker proxy method, which is the closest i got - it discovers the containers and populates them into HA, but then none of the sensor data or switches seem to actually work.

I attempted your solution from the guide you linked but this didn’t work at all :frowning:

Would super appreciate some help if anyone is willing :pray:

I post the guide that I wrote maybe you should read and try it. Please let me know which part fails?

hi! thanks for the offer of assistance :slight_smile:

I followed your guide which is very helpful, but i can’t seem to get it to work.

I believe i created all the certificates correctly and copied the three required into the /config/.certs/ folder (which i had to create myself) on my HA machine.

Then installed Monitor Docker and added the following to my config.yaml:

monitor_docker:
  - name: Docker
    url: tcp://192.168.1.180:2376
    certpath: '/config/.certs'

But when i restart HA, nothing is populated.

For reference, i have my containers running on a separate RPi to my HA server.

be sure proxy-server needs to be installed on your remote docker. Else it won’t work

yes, docker-socket is running on the RPi with the container on it:

what i’m wondering is if this command needs to be run on the HA machine or the one with the containers:

docker run --name docker-socket-proxy --restart always -d -p 2376:2376 -v /var/run/docker.sock:/var/run/docker.sock -v /usr/share/hassio/docker/certs:/run/secrets ranrinc/docker-socket-proxy

did you add certs into /config?

yes, i believe so. if i ssh into my HA machine, and type cd config, cd .certs and ls i see the following:

Screen Shot 2021-07-19 at 10.27.37

So, i assume that’s correct.

One thing i noticed that if i remove the line certpath: '/config/.certs form config.yaml and restart HA, the containers show up as entities, but i am unable to turn them on/off via HA

any error logs? need to get more info?

BTW did you run Supervised version?

heeem… when I said config its suppose to be HA home directory?

and config directory need to be allow

if by config you mean the same directory that contains, for example, the www directory and configuration.yaml, then yes :slight_smile:

How do i go about checking that it is set to allow?

on configuration.yaml

homeassistant:
  allowlist_external_dirs:
    - /config

here’s what the logs show after a reboot:

2021-07-19 10:43:31 ERROR (Thread-3) [custom_components.monitor_docker] DockerError(900, "Cannot connect to Docker Engine via tcp://192.168.1.180:2376 [Cannot connect to host 192.168.1.180:2376 ssl:default [Connect call failed ('192.168.1.180', 2376)]]")

2021-07-19 10:43:31 ERROR (Thread-3) [custom_components.monitor_docker] Retry in 60 seconds

sorry for security purposes… I think you can add a specific folder

1 Like

also i tried to change the port to 2375 (just to check) and got a slightly different error in the log after rebooting HA:

2021-07-19 10:48:04 ERROR (Thread-3) [custom_components.monitor_docker] DockerError(900, 'Cannot connect to Docker Engine via tcp://192.168.1.180:2375 [Cannot connect to host 192.168.1.180:2375 ssl:default [[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1125)]]')

2021-07-19 10:48:04 ERROR (Thread-3) [custom_components.monitor_docker] Retry in 60 seconds