Not sure if you are still trying to expose docker.sock, but here is the solution I use with monitor_docker. Thought I would document this here for anyone else having this issue.
I use docker compose file for HomeAss plus all my other containers. Rather than fight the fact that you cannot add docker.sock to the HomeAss container, instead “proxy” it.
I run HomeAssistant in an unsupported container config on a NUC. Tried to add docker.sock to my docker compose for HomeAssistant, but it never worked. When you add docker.sock via Portainer and restart HomeAssistant then you are not really changing “your” container, but rather Portainer is recreating a copy of yours and adding the docker.sock to that. If you do an upgrade then that copy (with the added docker.sock line) is trashed - which is the problem you are having.
The smarter, more permanent solution is to proxy docker.sock, and configure monitor_docker to use the proxy rather than docker.sock. If the HomeAssistant docker is re-created, upgraded, whatever then who cares because monitor_docker is just picking up the info from the proxy.
Long intro, sorry. Short solution:
- Create a proxy container
- Configure monitor_docker to use proxy
- There is no 3
So:
- Add the following to your docker compose file (I’m using port 2375 - feel free to change, but use the same port in the monitor_docker config in step 2 below):
# Proxy the Docker sock so that we can pick up stats for HomeAssistant
dockerproxy:
image: tecnativa/docker-socket-proxy
container_name: dockerproxy
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 2375:2375
environment:
- BUILD=1
- COMMIT=1
- CONFIGS=1
- CONTAINERS=1
- DISTRIBUTION=1
- EXEC=1
- IMAGES=1
- INFO=1
- NETWORKS=1
- NODES=1
- PLUGINS=1
- SERVICES=1
- SESSSION=1
- SWARM=1
- SYSTEM=1
- TASKS=1
- VOLUMES=1
- Change monitor_docker config to use port 2375 on the ip address you are running the docker image above.
monitor_docker:
- name: Docker
url: tcp://192.168.1.99:2375
# containers:
rename:
plex: Plex
# monitored_conditions:
- As I said, there is no step 3.