I wanted to see if I could create a smaller docker image then the current options available at github.com/openhab/openhab-docker.
I was able to create a much smaller working image based on Alpine Linux; 166MB vs 720MB:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
testing/openhab-alpine-3.5-aarch64 latest 972ffb817643 9 seconds ago 166MB
openhab/openhab 2.1.0-snapshot-arm64 4fd4f2a72745 3 weeks ago 720MB
Dockerfile
FROM multiarch/alpine:aarch64-v3.5
# Download URLs
ENV OPENHAB_URL="https://openhab.ci.cloudbees.com/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-2.1.0-SNAPSHOT.tar.gz"
# Set variables
ENV APPDIR="/openhab"
# Install packages
RUN apk update && \
apk add wget && \
apk add openjdk8
# Note: Azul JDK did not work for me, so using openjdk8
# Install openhab
RUN mkdir ${APPDIR} && \
wget -O openhab.tar.gz ${OPENHAB_URL} && \
tar -xzf openhab.tar.gz --directory ${APPDIR} && \
rm openhab.tar.gz
# Modify run script to use #!/bin/sh instead of #!/bin/bash
RUN sed -i "1s/bash/sh/" ${APPDIR}/runtime/bin/karaf
# Expose volume with configuration and userdata dir
VOLUME ${APPDIR}/conf ${APPDIR}/userdata ${APPDIR}/addons
# Execute command
WORKDIR ${APPDIR}
EXPOSE 8080 8443 5555
CMD ["./start.sh"]
Build
$ docker build . -t testing/openhab-alpine-3.5-aarch64
Run
docker run \
--name openhab \
-v /opt/openhab/conf:/openhab/conf \
-v /opt/openhab/userdata:/openhab/userdata \
-v /opt/openhab/addons:/openhab/addons \
-p 8080:8080 \
-p 8443:8443 \
-p 5555:5555 \
-d \
--restart=always \
testing/openhab-alpine-3.5-aarch64
I tested on Pine64-like hardware with a 4.10 linux kernel. This image will work on arm64 or aarch64 devices but it should also run on other devices like am64 by changing the FROM line, for example:
FROM multiarch/alpine:x86_64-v3.5