Docker NodeJS 运行 pulseaudio --system 无法打开 cookie 文件

Docker NodeJS run pulseaudio --system Failed to open cookie file

我正在尝试在 Docker 中获取一个 NodeJS 服务器 运行ning pulseaudio,用于屏幕录制 pupeter 浏览器。我已经省略了额外的部分,只包含了一个最小的例子来说明我遇到的问题。尝试 运行 pulseaudio --system 得到 Failed to open cookie file。我如何预先创建此文件或如何即时创建它。

Docker文件

FROM node:14

RUN apt-get update && apt-get install -y pulseaudio
RUN apt-get update && apt-get install -y pulseaudio-module-zeroconf
RUN apt-get update && apt-get install -y dbus-x11

RUN echo "load-module module-native-protocol-tcp auth-anonymous=1" >> /etc/pulse/default.pa
RUN echo "load-module module-zeroconf-publish" >> /etc/pulse/default.pa

COPY . .

CMD bash start_node.sh

start_node.sh

#!/bin/bash
service dbus restart
export $(dbus-launch)
pulseaudio --system

命令 运行

docker build -t pulseaudio .
docker run -it --rm pulseaudio

输出

[ ok ] Stopping system message bus: dbus.
[ ok ] Starting system message bus: dbus.
W: [pulseaudio] main.c: Running in system mode, but --disallow-exit not set.
W: [pulseaudio] main.c: Running in system mode, but --disallow-module-loading not set.
N: [pulseaudio] main.c: Running in system mode, forcibly disabling SHM mode.
N: [pulseaudio] main.c: Running in system mode, forcibly disabling exit idle time.
W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please make sure that you actually do want to do that.W: [pulseaudio] main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea.
W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file or directory

如果您使用 root 用户以使其正常工作,则需要启动 PulseAudio 守护程序。

将行改为 pulseaudio -D --system