Udevadm monitor in docker file

I am new to docker. Just managed to set it up, and try to get my segger JLink programmer running in a container with the following docker file.

FROM ubuntu


RUN apt-get update -y
RUN apt-get upgrade -y

RUN apt install libxcb-render-util0-dev -y
RUN apt install libxrender1 libxcb-shape0 libxcb-randr0 libxcb-xfixes0 libxcb-sync1 libxcb-shm0 libxcb-icccm4 libxcb-keysyms1 libxcb-image0 libxkbcommon0 libxkbcommon-x11-0 libfontconfig1 libfreetype6 libxext6 libx11-xcb1 libsm6 libice6 libglib2.0-0 -y

RUN apt install udev -y
RUN /lib/systemd/systemd-udevd --daemon
RUN udevadm monitor &

RUN mkdir -p /home/Downloads
COPY JLink_Linux_V766c_x86_64.deb /home/Downloads/JLink_Linux_V766c_x86_64.deb

# RUN dpkg -i /home/Downloads/JLink_Linux_V766c_x86_64.deb

CMD bash

I need to comment out 1 line (RUN dpkg -i) because it fails with the following error:

Failed to send reload request: No such file or directory
3-2: Failed to write ‘remove’ to ‘/sys/devices/pci0000:00/0000:00:08.1/0000:05:00.4/usb3/3-2/uevent’: Read-only file system
3-2: Failed to write ‘add’ to ‘/sys/devices/pci0000:00/0000:00:08.1/0000:05:00.4/usb3/3-2/uevent’: Read-only file system

I can resolve this error by issueing the command udevadm monitor & in my docker. Once the monitor is running, I can install my segger JLink and use it without any problems.

But, now I need to install segger JLink every time I start my container, and that’s not what I want :slight_smile: .

So I tried to simply add RUN udevadm monitor & in my docker file, but that doesn’t seem to do the trick.

How can I resolve the error the best way?

Ah, found the answer but it doesn’t solve anything. I can run something which is clearly not preferred according to official docs

RUN nohup bash -c "udevadm monitor &" && sleep 4

But the problem I am facing, is that I need peripherals of the host system, during build time of the image. And that seems not to be supported.

After some googling I found the best way was to simply don’t execute the post inst actions. I stole this from stackoverflow

RUN dpkg --unpack /home/Downloads/JLink_Linux_V766c_x86_64.deb
RUN rm /var/lib/dpkg/info/jlink.postinst -f
RUN dpkg --configure jlink
RUN apt install -yf 

That works perfectly for me

1 Like

Each RUN instruction is run inside a new temporary container - so if you depend on something running during the installation, then make sure to perform all required operations in the same RUN instruction and chain them by && or ;, use \ with no trailing space at the end for linebreaks.

Though, nothing you start while building the image will be running when you create a container based on this image. Whatever you declare as ENTRYPOINT or CMD needs to take care of this as those instruction are what actualy is executed hen the container is started.