I am trying to access a NI cDAQ device from a Python script in a Docker container, using this python script (as a start):
import nidaqmx
task = nidaqmx.Task()
task.do_channels.add_do_chan(lines="cDAQ1Mod1/port0/line0")
task.write(1)
I have failed to install the device driver using this Dockerfile:
FROM ubuntu:latest
ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt-get install -y \
apt-utils \
python3 \
pip
RUN pip install --no-cache-dir nidaqmx
COPY ni_drivers.deb ./
RUN apt install ./ni_drivers.deb
RUN apt update && apt install -y \
ni-xnet \
ni-daqmx \
ni-serial
RUN dkms autoinstall
COPY hellodaq.py ./
CMD ["python3", "./hellodaq.py"]
During the build, I get the following message:
Error! Bad return status for module build on kernel: 5.15.0-43-generic (x86_64)
Consult /var/lib/dkms/ni843x/21.5.0f124/build/make.log for more information.
dpkg: error processing package ni-843x-dkms (--configure):
installed ni-843x-dkms package post-installation script subprocess returned error exit status 10
And ultimately:
E: Sub-process /usr/bin/dpkg returned an error code (1)
(whats the best way of reading var/lib/dkms/ni843x/21.5.0f124/build/make.log? Since the build fails I cannot run the container.)
Therefore I tried to run the script in a Docker without the device driver:
FROM ubuntu:latest
RUN apt update && apt-get install -y \
python3 \
pip
RUN pip install --no-cache-dir nidaqmx
COPY hellodaq.py ./
CMD ["python3", "./hellodaq.py"]
As a replacement, I tried to mount the device driver from the host system:
sudo docker run \
--mount type=bind,source=/usr/lib/x86_64-linux-gnu/ni-daqmx,target=/usr/lib/x86_64-linux-gnu/ni-daqmx \
--mount type=bind,source=/usr/share/ni-daqmx,target=/usr/share/ni-daqmx \
hellodaq
However, this has not resolved the issue, and the python script cannot access the device driver.
Is it even possible to mount installed deb packages, device drivers specifically? Did I forget a step, i.e. adding the device driver to the PATH in the Docker container? (is that a thing?)
Is there some alternative way to do access the cDAQ from a Docker container?