With the container init scripts support, a custom image is no longer needed for this use case. Here is the updated setup I am now using:
cont-init.d/50-exec-scripts
#!/usr/bin/with-contenv bash
# Include openhab scripts folder in path
export PATH=${OPENHAB_CONF}/scripts:${PATH}
# Install additional packages
apt-get -qq update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y \
curl \
jq \
python \
python-pip \
python-setuptools \
python-wheel
# Install python required packages
pip install -q --no-cache-dir \
<required_pkg_1> \
<required_pkg_2> \
...
docker-compose.yml
version: '3'
services:
openhab:
image: openhab/openhab:snapshot
container_name: openhab
restart: always
network_mode: host
tty: true
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./addons:/openhab/addons
- ./conf:/openhab/conf
- ./cont-init.d:/etc/cont-init.d
- ./userdata:/openhab/userdata
environment:
OPENHAB_HTTP_PORT: 8080
OPENHAB_HTTPS_PORT: 8443
USER_ID: 9001
GROUP_ID: 9001
Commands
To pull latest openHAB snapshot
docker-compose pull
To create/start the container:
docker-compose up --detach
To delete/stop the container:
docker-compose down