Using OpenHab3 in Docker with an WQHD Camera

Q: I am using OpenHab in Docker and tried to add my camera using the ipcamera binding. But I am unable to access the video stream or snapshot. Even though the binding shows that my camera is connected.

A: When you are using Docker to run OpenHab we recommend that you set the Network Mode to host. This way your container is directly connected to your local network and will be able to communicate with your camera. For example on a Linux system you can first create the folders you want to use to persists the data OpenHab will generate:

mkdir /opt/openhab

Make sure that the docker container is allowed to write into this folder!

Now you can start the container with - note the --net=host flag:

docker run \
    --name openhab \
    --net=host \
    --privileged \
    --rm \
    -v /etc/localtime:/etc/localtime:ro \
    -v /opt/openhab/openhab_addons:/openhab/addons \
    -v /opt/openhab/openhab_conf:/openhab/conf \
    -v /opt/openhab/openhab_userdata:/openhab/userdata \
    -d \
    openhab/openhab

When you log in to OpenHab you will see that it is using the "wrong" network interface. The streaming port will be bound to the internal Docker container IP - which is not accessible from your local network:

Using OpenHab3 in Docker with an WQHD Camera

Open up the Network settings:

Using OpenHab3 in Docker with an WQHD Camera

And select the network interface of your local machine:

Using OpenHab3 in Docker with an WQHD Camera

To restart OpenHab you need to remove the container:

docker rm -f openhab

And use the docker run command from above again to restart it. Now you can see that the camera binding is using the correct network interface:

Using OpenHab3 in Docker with an WQHD Camera