Best way to add udev rules

I would like to update all the devices of my fleet with a udev rule that loads a usb to rs-232 adapter as soon as it is plugged in.
I have successfully updated the rule in one device logging through ssh and writing it to config.json.
I would like to know:
1- What would be the best way to automate adding this rule in already staged devices (no physical access)
2- How to automate adding this rule to my build so new staged devices ship with that rule already installed without manually mounting the image and modifying config.json

I’ve seen how to add the rules to my containers but I believe this rule needs to go in the Host OS (correct me if I’m wrong).
Also I’ve seen some declined PRs that aimed at adding udev rules from the dashboard, I might have missed the final docs on this.
EDIT: I already have udev enabled in my container but that alone did not work, I need the udev rule
ENV UDEV=on

1 Like

Answering my own question, yes this works, credit to this answer

Add ENV UDEV=on and add a line in the Dockerfile that copies the *.rule to /etc/udev/rules.d/

2 Likes