Exposing docker.sock for monitor_docker

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: GitHub - ualex73/monitor_docker: Monitor Docker containers from Home Assistant

  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

3 Likes

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

Quick question, yes it works now from my current Docker. However, I do have an extra docker container in another machine and would like to get data from it. Is there a way to remotely grab it? Using portainer can be easily done but how to setup from HA?

1 Like

how do you show Portainer in HA Backend? :slight_smile: Thanks

Install the portainer add-on.

1 Like

Check point for of the QA in the monitor docker docs -> https://github.com/ualex73/monitor_docker#qa you can monitor them over tcp.