只需要挂载 /dev/snd 同时开放硬件访问权限即可
- docker run -ti --rm \
- --device /dev/snd \
- cmus
-
需要挂载 /dev/shm, /etc/machine-id, /run/user/$UID/pulse 和 /var/lib/dbus (因为有些应用通过访问 /var/lib/dbus/machine-id 来获取 machine id),同时环境变量 XDG_RUNTIME_DIR 的值也需要跟主机系统一致
- docker run -ti --rm \
- --device /dev/shm \
- -v /etc/machine-id:/etc/machine-id \
- -v /run/user/$uid/pulse:/run/user/$uid/pulse \
- -v /var/lib/dbus:/var/lib/dbus \
- -e XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} \
- myContainer