如何从Docker容器获取主机的udev事件? [英] How to get host's udev events from a Docker container?

查看:359
本文介绍了如何从Docker容器获取主机的udev事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Docker容器中,我正在寻找一种在主机上获取udev事件的方法。

使用 udevadm Monitor ,它将发回主机的内核事件仅在容器中。

In a Docker container, I am looking for a way to get the udev events on the host.
Using udevadm monitor, it sends back host's kernel events only in a container.

问题是是否存在检测主机的udev事件或将主机的事件转发到容器的方法?

The question is whether there is a way to detect host's udev events or forward host's event to containers?

推荐答案

这就是我如何使容器接收udev的主机事件:

This is how I made my container receive host events by udev:

docker run --net=host -v /run/udev/control:/run/udev/control

-net = host允许容器和主机通过PF_NETLINK套接字进行操作,udev Monitor使用该套接字接收内核事件(此处

--net=host allows container and host operate through PF_NETLINK sockets, which are used by udev monitor to receive kernel events (found here)

/ run / udev / control是一个文件,udev监视器使用该文件检查udevd是否已在运行。如果不存在,则禁用监视。

/run/udev/control is a file, which udev monitor uses to check if udevd is already running. If it doesn't exist, monitoring is disabled.

这篇关于如何从Docker容器获取主机的udev事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆