Exposing docker.sock for monitor_docker

Excused my stupidity as I don’t know an awful lot of docker.

To use the monitor_docker add-on for HA, I must bind the volme var/run/docker.sock into the container to see the sensors.

(EDIT - If you do not know how to do bind the volume so you can use monitor_docker, see my comments in post 10)

However, once I then update HA, this is removed from the docker rebuild and I need to re-bind the volume before the monitor_docker sensors reappear.

Is there something I can do to prevent this?
Thanks

is it an addon? There is a HA dockermon I use that is an external docker container which is loaded by docker-compose so not exactly sure what you are trying to do. What HA did you install?

Hi David

It’s https://github.com/ualex73/monitor_docker
It gives a lot more info about the containers tha HA dockermon (I believe, not used it though but just reading the docs).
I believe it was written to get the best from HA dockermon and a precious docker_monitor add-on which are both no longer developed?
Anyway, I think that dockermon runs as a container, so can always re-bind docker.sock when you update it, however monitor_docker is an integration within HA so when HA is updated, there is no reason for it to rebind the .sock

yeah so I was confused because you called it an addon whereas it’s an integration.
You didn’t say what you installed but I’m guessing it’s HA OS?

What exactly are you trying to do with it? You don’t have that many options for this with HA OS but maybe you can get the functionality you want using Glances…

Hi David,

Monitor_Docker does exactly what I want it to do so id rather stay with that as its tidier (assuming I could get the .sock to bind every time). Ill send a picture of my dashboard with this information on later this eveing.

I could get the same info but would need to user HA dockermon and Glances so would be more work.

Im running Home Assistant as a Docker image on Ubuntu.

If it’s not a supervised install you should be able to make it stick from the command line then and use docker-compose as per the instructions. Even with supervised (non HA OS) you should be able to do that I would have thought

Here are screenshots of what I use monitor_docker for

The problem is that I dont use docker-compose to recreate the home assistant instance upon upgrade, I just click “Upgrade” from the Supervisor section of HA.

and you shouldn’t do that anyway… let the supervisor manage HA as it’s intended.
But I don’t understand why you don’t just use docker-compose with say a script and a cronjob at the OS level - that’s what I do. I have a HA supervised install and I use docker-compose only to manage some extra non-HA containers and a cronjob basically checks for updates to the images for those containers every 12 hours and updates as required.

How are you even making this run from inside HA anyway? Are you ssh’ing into the HA container to do the mapping? Have you considered using portainer to create a stack to do this? Theres a bunch of easy ways to make this work but maybe I’m just not understanding what you are trying to do.

I could create the exact same dashboards using hadockermon as you are and get everything there using Glances except the restart buttons…

Hi, how you add the docker.sock? @Craig_McGowan

i have this Error: Can not connect to Docker API (Missing valid docker_host.Either DOCKER_HOST or local sockets are not available.)

Q&A: https://github.com/ualex73/monitor_docker#qa

  1. Error: Missing valid docker_host.Either DOCKER_HOST or local sockets are not available.
    Answer: Most likely the socket is not mounted properly in your Home Assistant container. Please check if you added the volume /var/run/docker.sock

This is my Docker/Portainer:

Thanks for help

Hi @basti4k
In portianer, go to your homeassistant container. Scroll down to the Volumes.
You should not see /var/run/docker.sock listed which is the problem.

Scroll back up to Edit the container. Then go into the Volume section and “map additional volume”.

Add in /var/run/docker.sock from the Container and bind it to /var/run/docker.sock in the host.

It should look like

Then rebuild the container. Check back in the container at the volumes and check its now a binded volume. If it is, monitor_docker should now work for you

My problem is that every time Home Assistant is updated, I need to redo this step.

Kind regards

1 Like

Hi @Craig_McGowan thanks for the fast Solution.
But i dont have a “Edit” Button. Only “Duplicate/Edit”.

i can add the Volume, but i dont see a “Save” Button.

at the top:

Caution

The new container may fail to start if the image is changed, and settings from the previous container aren’t compatible. Common causes include entrypoint, cmd or other settings set by an image.

i hope you can help me again :slight_smile: thanks!

Hi Sebastian,

Yes the Edit Button is the Duplicate/Edit so you are in the right place.

Instead of Save sorry, hit “Deploy the container”.

Kind regards

1 Like

very nice, it works! after a new Update i hope it works again, i give you a Info.

Unfortunately it won’t and you will need to re-bind the volume.
This is the problem I have and why I opened this thread.
If you manage to work out a way to keep it persistent through upgrades please let me know.

1 Like

mhh, and if you open a issue in git?

I don’t believe it’s an issue. It’s just as HA recreates it’s container when upgrading with its set variables and this isn’t one of them. I have asked in git for the monitor_docker page for help but no feedback as of yet.

okay, now i install the new HA Version, and now he delete the volume :frowning:

Missing valid docker_host.Either DOCKER_HOST

Yeh, youll need to follow the instructions I listed above again unfortunately.

1 Like

yes i do. Thanks. But this is a shit Solution :smiley:

Thanks @Craig_McGowan you are a savior…

2 Likes