如何在 Docker/Linux 上启动 dbus?无法连接到总线:无法连接到套接字 /run/dbus/system_bus_socket:没有该文件或目录

如何在 Docker/Linux 上启动 dbus?无法连接到总线:无法连接到套接字 /run/dbus/system_bus_socket:没有该文件或目录

我在 Docker 中通过 Node.js 运行 puppeteer,并且这个错误在不对 dbus 进行任何操作之后:

puppeteer:browsers:launcher Launching /usr/bin/google-chrome --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-field-trial-config --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --generate-pdf-document-outline --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold --enable-features=NetworkServiceInProcess2 --headless=new --hide-scrollbars --mute-audio about:blank --no-sandbox --disable-setuid-sandbox --user-data-dir=/tmp --remote-debugging-port=0 {
  detached: true,
  env: { PUPPETEER_LOGLEVEL: 'warn' },
  stdio: [ 'pipe', 'pipe', 'pipe' ]
}
puppeteer:browsers:launcher Launched 77
[77:99:0212/184919.101915:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
... 2 minutes pass ...
[77:103:0212/185058.541101:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:103:0212/185058.545833:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:99:0212/185058.659905:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664100:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664193:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664208:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185100.545069:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185100.545120:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
DevTools listening on ws://127.0.0.1:39321/devtools/browser/c2bc3dd3-e056-4850-80d3-03782d2bbde9
puppeteer:protocol:SEND ► [
  '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":1}'
]
[77:146:0212/185102.787508:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787592:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787668:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787814:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787863:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"75B8C5DD3A56E651FB1725FD3E7F6890","type":"page","title":"","url":"about:blank","attached":false,"canAccessOpener":false,"browserContextId":"6533EE3CE11CFE6B1647EE8CCACB8D60"}}}'
]
... then it finally starts to log a lot and work ...

现在我尝试将其添加到我的 Dockerfile 中:

CMD ["sh", "-c", "./start.sh"]

我在里面做了:

export DBUS_SESSION_BUS_ADDRESS=`dbus-daemon --fork --config-file=/usr/share/dbus-1/session.conf --print-address`

现在我得到:

Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
DevTools listening on ws://127.0.0.1:39453/devtools/browser/385fdb87-fa48-4bd2-b67d-2c5d501fa75a
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

我怎样才能让它工作?

相关内容