Matrix Lite Js in Docker Container

Hi,
I am trying to use the @matrix-io/matrix-lite node package in a docker container. My Dockerfile looks like this:

FROM balenalib/raspberry-pi-debian-node:latest

USER root
RUN apt-get update && \
    apt-get install apt-transport-https curl systemd python build-essential -y && \
    curl https://apt.matrix.one/doc/apt-key.gpg | apt-key add - && \
    echo "deb https://apt.matrix.one/raspbian buster main" | tee /etc/apt/sources.list.d/matrixlabs.list && \
    apt-get update && \
    apt-get install libmatrixio-creator-hal libmatrixio-creator-hal-dev -y

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
COPY package-lock.json /usr/src/app/

# also installs @matrix-io/matrix-lite
RUN npm install

# Bundle app source
COPY . /usr/src/app

# Port to listener
EXPOSE 8282

# Main command
CMD [ "npm", "run", "start" ]

I also activated the i2c interface, installed the matrixio-kernel-modules and matrix-creator-init on my raspberry host system. Now when starting a docker container using the Dockerfile above the following error occurs:

can't open any device
internal/modules/cjs/loader.js:1189
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^
Error: matrixio_bus not initialized!
Is MATRIX HAL installed?
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1189:18)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/src/app/node_modules/@matrix-io/matrix-lite/index.js:1:7)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

How can I get this to work? Thanks!

It’s working now, I just had to start the container with --privileged

2 Likes