Skip to content

doc(Docker): document running in Docker#120

Open
bentolor wants to merge 1 commit into
fl4p:masterfrom
bentolor:doc/build-and-run-in-docker
Open

doc(Docker): document running in Docker#120
bentolor wants to merge 1 commit into
fl4p:masterfrom
bentolor:doc/build-and-run-in-docker

Conversation

@bentolor

Copy link
Copy Markdown

While I failed to get the setup running for me (I have a SmartSolar and it seems it uses a different approach, See https://community.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html. And my LifePO4 BMS seems to be out of bluetooth reach), I still documented the necessary steps for clarity.

Watch out my change in run.sh. No clue how this is supposed to run.

@fl4p

fl4p commented Dec 16, 2023

Copy link
Copy Markdown
Owner

Why are you running this in Docker? batmon supports all mayor operating systems.

And whats the reason building this from homeassistant/amd64-base:latest? Batmon doesn’t use any HA specific binaries.
minimal alpine linux should be just fine. Whats the size of homeassistant/amd64-base:latest ?

The Dockerfile is meant to be for HA add-on interface. HA chooses the right base image, see
https://developers.home-assistant.io/docs/add-ons/configuration/

I don't recommend running batmon in Docker anyway. Better to run this directly on the host, it doesn't open any port.
Docker is often unnecessary.

@bentolor

bentolor commented Dec 16, 2023

Copy link
Copy Markdown
Author

Why are you running this in Docker?

All my production workloads are portable, decoupled from host environment, using isolated environments and lightweight.

And whats the reason building this from homeassistant/amd64-base:latest

Obviously I tried to adopt the existing blueprint. I remember some weird dependencies to S7 and it seemshomeassistant/amd64-base:latest provides that.

@brilthor

brilthor commented Jul 9, 2026

Copy link
Copy Markdown

EDIT: sorry I narco-bumped this, I didn't realize it was from 2023

@bentolor I also run it under docker since through decades of admin experience I have leaned to shy away from non-package manager installs of software on multi-purpose servers.

Here is a repo which does a multi-platform build script: https://github.com/sashasimkin/batmon-docker. I'm not sure if it would be good to port that to this repo or if the maintainer doesn't want automatic builds for some reason to update the other.

I found I had to override the command in docker compose since the initialization script seems to break pretty hard when just moving over to bash as the interpreter, what was your experience?

@bentolor

bentolor commented Jul 9, 2026

Copy link
Copy Markdown
Author

@brilthor no worries.

Just my 2c: Eventually I resorted to using an ESP32 with ESPHome and github://Fabian-Schmidt/esphome-victron_ble which worked quickly, out of the box and quite reliably the past years.

fl4p added a commit that referenced this pull request Jul 10, 2026
Make addon_main.sh bashio-optional so the same Dockerfile builds both the HA
add-on and a standalone image (BUILD_FROM=alpine). A new entrypoint.sh dispatches
on /usr/bin/with-contenv. Publish ghcr.io/fl4p/batmon-ha (amd64/arm64/armv7) and
add a Helm chart.

Community images that ran addon_main.sh by rewriting its shebang to /bin/sh
silently disabled bumble/bluek/esphome and always used bleak.

Fixes:
- MQTT_HOST/PORT/USER/PASSWORD from `docker run -e` were overwritten with empty
  strings when no Supervisor MQTT service was present
- options.json without ble_stack skipped the pairing pre-step instead of
  defaulting to bleak
- a failing pair-only step was swallowed on the non-bashio path
- docker stop now terminates promptly (entrypoint execs python)
- add .dockerignore so a local build no longer bakes options.json credentials in
@fl4p

fl4p commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Thanks for kicking this off. I ended up shipping standalone Docker support in a way that keeps a single Dockerfile for both the add-on and standalone: addon_main.sh is now bashio-optional and a new entrypoint.sh dispatches between the two, so ble_stack (bumble/bluek/esphome) keeps working outside HA instead of silently falling back to bleak. Landed in 2.04 (commit f9a76ea) with doc/Docker.md, an options.json.template, a multi-arch image at ghcr.io/fl4p/batmon-ha (amd64/arm64/armv7), and a Helm chart.

Note your patch targeted run.sh, which has since been renamed to addon_main.sh. Closing this out as superseded — thanks again for the nudge to get it done.

@fl4p

fl4p commented Jul 10, 2026

Copy link
Copy Markdown
Owner

And notice that I implemented two new bluetooth stacks in batmon, bluek (DBus bypass) and bumble (exclusive adapter access).
If you ever want to give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants