I’ve updated my HA image from 0.97 to 0.98.2 a few minutes ago and I’ve noticed all the python scripts regarding turning on and off my projector weren’t working anymore.
I’ve logged into the docker image and noticed since HA is running on Alpine, python wasn’t part of the image… I’ve decided to install python manually into the image itself by entering those commands:
Remote connect into the Bash environment of the Docker Image:
sudo docker exec -[Docker Image Name] /bin/bash
Once logged into bash:
apk add --no-cache python
Now, everything works… but by doing this, I know the next time I’ll update the Docker Image, I’ll need to install Python manually.
So, the question I have right now is… have I done the right thing? Is there a solution that would allow me to install python once in a permanent way so it would last even if I update the image again?
Looks like python is installed in /usr/local and not via apk. If python weren’t installed, Home Assistant couldn’t run. I didn’t use any docker images prior to 0.98.2 so I wouldn’t know, but could it be the path changed and your scripts are referencing a python in the wrong location?
$ docker exec -it home-assistant /bin/bash
bash-5.0# which python3
/usr/local/bin/python3
bash-5.0# echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
bash-5.0# apk list --installed | grep python
WARNING: Ignoring APKINDEX.00740ba1.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.d8b2a6f4.tar.gz: No such file or directory
.python-rundeps-20190812.220046 noarch {.python-rundeps} () [installed]
bash-5.0# ps -ef
PID USER TIME COMMAND
1 root 0:05 /sbin/docker-init -- /bin/entry.sh python3 -m homeassistant --config /config
6 root 20:26 /usr/local/bin/python3 -m homeassistant --config /config
8 root 0:00 udevd --daemon
44 root 0:00 bash
68 root 0:00 /bin/bash
78 root 0:00 ps -ef
You build your own image based on the image you selected. Basically if you want to add functionality to a docker image you build FROM that image and inject your added applications etc.
But at this point in time, it would be impossible for home assistant to ship without python since it literally runs on python
Yeah I know for Home Assistant it wouldn’t ship without Python… but I’m quite new with Docker too… so I was asking in general… just to get better with that wonderful tool I’m using for a month or so! Thanks for taking the same to answer! Much appreciated!
Just to expand on the subject, the point of docker is that a developer can release a packaged way of running their software without worrying about dependencies. So the same environment the developers wrote the software in is the same environment you run. You never have to worry about dependencies and making sure you have the correct version of application X so that it doesn’t interfere with application Y. Once you wrap your head around it, it becomes quite clear and the logic just makes sense.