T7 Docker support | LabJack
 

T7 Docker support

11 posts / 0 new
Last post
oto
ossiouri's picture
T7 Docker support

Hi labjack support, 

Does T7 support installing and running software from docker container?

I actually tried this with ubuntu 18.04 based container but labjac_ljm_installer.run does not finish as expected (done and Install finished never got). 

"Adding LabJack device rules... done.
restarting the device rules... "

And eventually connection fails. Any docker experiences, guides or plans?

Best regards, 

- T7 user with dockerized test environment

LabJack Support
labjack support's picture
The "restarting the device

Update 2020-07-03:

Official LabJack LJM Docker image here: https://hub.docker.com/r/labjack/ljm

Information and usage details: https://github.com/labjack/ljm_docker

 

The "restarting the device rules..." line happens immediately before the installer attempts the command:

udevadm control --reload-rules 2> /dev/null

Adding a RUN which udevadm to the Dockerfile fails, as do other methods of restarting udev rules (/etc/init.d/udev-post does not exist, nor does udevstart).

It looks like you might be able to write a custom udev rule for the host and mount the pertinent subdirectory to your container (e.g. docker run -v=/dev/foo:/dev/foo) as according to here:

https://stackoverflow.com/questions/36880565/why-dont-my-udev-rules-work...

If you do that and send us the result, we could send you a version of the LJM installer that doesn't attempt to restart the udev rules, or has some other workaround, depending on what we can find. From there, there may be other problems. For example, libusb probably needs to be installed.

How does that sound? Is there a different approach we should take? Please send any good documentation / examples that you have.

For future reference, I've attached a small example (which fails) adapted from the Docker Get Started guide. The command I used to test it was:

docker build -t ljm ljm_docker_test && docker run -p 80:80 ljm

File Attachment: 
oto
ossiouri's picture
Thanks for your great

Thanks for your great response. I will study that attacment in more detail. I found out that I was missing udev tools from docker container. Now added and actually some progress as the installer finishes now. Unfortunately some connection problem still. As a background I'm connecting to labjack via ethernet.

Here's my current docker run command: 

docker run -it -v /home/<username>/project/docker/py3:/opt/robot -v /run/udev:/run/udev:ro -v /dev/bus/usb:/dev/bus/usb --network=host --privileged otorf

and my Dockerfile is like this: 

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y wget python3-pip udev
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
WORKDIR /tmp
RUN wget https://www.labjack.com/sites/default/files/software/labjack_ljm_softwar...
RUN tar -zxf labjack_ljm_software_2018_05_15_x86_64.tar.gz
ADD r.sh /tmp
CMD sh /tmp/r.sh

and r.sh script is like this: 

./labjack_ljm_software_2018_05_15_x86_64/labjack_ljm_installer.run
pip3 install --no-cache-dir https://labjack.com/sites/default/files/software/Python_LJM_2018_02_23.zip
robot /opt/robot/aout/first.robot

 

Seems I'm not finding the library as the test fails: 

AttributeError: 'NoneType' object has no attribute 'LJM_Open'

Without docker container test passes. I wonder if I need to expose something more to container? Something to do with ldconfig? I guess no own rules needed? 

 

LabJack Support
labjack support's picture
I'm not sure why you're

I'm not sure why you're getting the AttributeError, but I made another bundle that installs LJM shared libraries and LJMPython, then starts a .py file that successfully imports LJM and calls listAll. Unfortunately, I'm on macOS and can't use docker's --network=host, so the container isn't able to actually broadcast to the network and therefore never finds any devices. Since you can use --network=host, it might work for you. Please try it out and let us know.

ljm_docker_test_2018_06_15.zip:

  • Uses a custom version of the labjack_ljm_software installer (included in the .zip) that omits the udev stuff because I wasn't able to get past it with just apt-getting udev.
  • apt-gets libusb-1.0-0-dev as a workaround.
oto
ossiouri's picture
Good news. When I change to

Good news. When I change to use your custom version of the labjack_ljm_software_installer and I install libusb-1.0-0-dev then I can run my tests succesfully in docker environment. All steps done during docker build phase as in your example. Cool! 

I shall play around a bit more to understand if any limitations. 

 

 

oto
ossiouri's picture
Well, looks good. I also ran

Well, looks good. I also ran your docker file and 9 devices found. Thank you for your great support. 

Any comments about the official support for docker containers? And how about supporting small size linux distro. Personally Alpine would be awesome. 

LabJack Support
labjack support's picture
Sorry for the delay. We haven

Sorry for the delay. We haven't had enough requests for Docker to make it happen yet. Anyone else that wants Docker can comment in this thread or email us at [email protected].

LabJack Support
labjack support's picture
Since the problem with the

Since the problem with the LJM installer is that the udev rules should not be restarted (it causes an error), the LJM installer will have an option to not run the udev rules. From 2019-07-16 (LJM 1.20.1) and onwards, the Linux LJM installer supports the --no-restart-device-rules flag, which may be invoked with an extra -- as shown:

./labjack_ljm_installer.run -- --no-restart-device-rules

brandon_moog
brandonm's picture
Hello!

Hello!

So after much effort I was able to follow this thread and get LJM working in my docker container! Thank you for adding the --no-restart-device-rules option.

 However, i'm unable to connect to my labjack. Are there any reccomendations for actually connecting the T7 to the container? When i search for available devices in my python code I get:

LJM library error code 1314 LJME_NO_DEVICES_FOUND

LabJack Support
labjack support's picture
Does lsusb show the LabJack?

Does lsusb show the LabJack?

What flags are you passing to docker run? Maybe someone familiar with those flags can help out. It looks like there's some complications around allowing a Docker to access host devices.

Is using an Ethernet connection an option?

Rory
Rory's picture
Official LabJack LJM Docker

Official LabJack LJM Docker image here: https://hub.docker.com/r/labjack/ljm

Information and usage details: https://github.com/labjack/ljm_docker