-
Notifications
You must be signed in to change notification settings - Fork 153
Docker
John Blance edited this page Jul 10, 2024
·
12 revisions
on a fresh raspbian lite install
- install git
sudo apt-get install git
- install docker
curl -fsSL https://get.docker.com -o get-docker.sh
and thensudo sh get-docker.sh
- allow current user to run containers
sudo usermod -aG docker [user_name]
- assuming docker is install (otherwise see next section)
- pull image
$ docker pull jblance/mppsolar
Using default tag: latest
latest: Pulling from jblance/mppsolar
f03b40093957: Already exists
05c2151a829c: Already exists
413e4e4760ae: Already exists
92ec8b395aa1: Already exists
295d2f1818b0: Already exists
7f5a0b1f1088: Already exists
Digest: sha256:a2861b484549d3351adc69b84251a75386033dc4fb88f57c94c018d8db569ac1
Status: Downloaded newer image for jblance/mppsolar:latest
docker.io/jblance/mppsolar:latest
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jblance/mppsolar latest 56784f786abf 58 minutes ago 151MB
- if wanted, add a simpler tag (for easier running)
$ docker tag jblance/mppsolar mpp
REPOSITORY TAG IMAGE ID CREATED SIZE
jblance/mppsolar latest 56784f786abf About an hour ago 151MB
mpp latest 56784f786abf About an hour ago 151MB
- run a test command
$ docker run --rm mpp mpp-solar -v
Solar Device Command Utility, version: 0.15.59
- clone git repo
- ensure you have setup ssh key for git https://docs.github.com/en/authentication/connecting-to-github-with-ssh
- clone repo
git clone [email protected]:jblance/mpp-solar.git
- create Dockerfile as below
FROM python:3.10-slim
COPY ./mpp-solar /mpp-solar/
RUN pip install -e /mpp-solar/
should have:
~ $ ls -l
-rw-r--r-- 1 pi pi 84 May 18 15:16 Dockerfile
drwxr-xr-x 12 pi pi 4096 May 17 10:00 mpp-solar
- build an image and tag it
$ docker build -t mp .
- then commands can be run against it
$ docker run --rm mp powermon -C /mpp-solar/powermon/config/min.yaml
$ docker run --rm --device=/dev/hidraw0 mp mpp-solar -p /dev/hidraw0 -P pi30max -c QPI
- prepare Dockerfile
FROM python:3.11-slim
RUN pip install mppsolar
- build image
$ docker build -t jblance/mppsolar:0.15.62 .
- tag as latest
$ docker tag jblance/mppsolar:0.15.62 jblance/mppsolar:latest
- login
$ docker login -u username
- push to dockerhub
$ docker push jblance/mppsolar:0.15.62
- push latest tag
$ docker push jblance/mppsolar
created / tested by Rob Wolff
- Download the Dockerfile here or copy and paste below to the Docker server you want to run the mpp-solar container on:
FROM python:3.10.4-slim-bullseye
RUN apt update
RUN apt-get install -y pkg-config libsystemd-dev gcc
RUN pip install paho-mqtt systemd-python mppsolar
WORKDIR "/etc/mpp-solar"
CMD mpp-solar -C mpp-solar.conf --daemon
-
In the same folder as the Dockerfile run
docker build -t mpp-solar .
to build the container. -
Create a config file called
mpp-solar.conf
where the rest of your docker config files are stored. Reference the mpp-solar config file documentation here or see mine as an example below:
[SETUP]
pause=1
mqtt_broker=MQTTHOST
mqtt_user=MQTTPASS
mqtt_pass=MQTTUSER
[LVX6048WP]
port=/dev/ttyUSB0
protocol=PI17
command=GS#PS
tag=mpp
outputs=hass_mqtt
- Run the container using Docker command:
$ docker run -d --name=mpp-solar \
--restart unless-stopped \
-v ${CONFIGDIR}/mpp-solar:/etc/mpp-solar \
--device /dev/ttyUSB0:/dev/ttyUSB0 \
--privileged \
mpp-solar
Or run the container using Docker Compose:
version: '3'
services:
mpp-solar:
image: mpp-solar
container_name: mpp-solar
privileged: true
restart: unless-stopped
volumes:
- ${CONFIGDIR}/mpp-solar:/etc/mpp-solar
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
docker run --rm --network=host -v ./docker/mosquitto/config:/mosquitto/config eclipse-mosquitto