node.js - Docker NodeJS 运行 pulseaudio --system 无法打开 cookie 文件
问题描述
我正在尝试让 NodeJS 服务器在 Docker 中运行 pulseaudio,以便对 pupeteer 浏览器进行屏幕录制。我已经把多余的部分去掉了,只包含了一个最小的例子来解决我遇到的问题。试图运行pulseaudio --system
给出Failed to open cookie file
. 我如何事先创建这个文件或让它动态创建它。
Dockerfile
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
推荐阅读
- tensorflow - 在 Windows 上的张量流中调用检查点时出错
- xml - web xml spring中contextconfiglocation的用途是什么?
- maven - 在 STS 中找不到 Tomcat
- c - C中的冒泡排序输出问题
- php - FatalErrorException 调用字符串 Laravel 5.4 上的成员函数 diffForHumans()
- android - 我正在尝试使用 Ionic 框架构建 apk
- javascript - 添加java函数时Android Studio没有响应
- python - 无法在 Django 中存储多个图像
- python - 如何在 ModelResource django-import-export 中获取请求
- jquery - 从 Jquery 库中获取默认值而不是用户输入的值