原理
Docker支持圖形化程序,是利用Linux的X11技術。
相關文章
引文詳情
如何在Docker容器中啟動D-Bus
翻譯自 https://georgik.rocks/how-to-start-d-bus-in-docker-container/
很多Linux應用需要用到 D-Bus, 但它在Docker容器中默認並不存在
當你嘗試啟動這類應用時,你會收到一個錯誤信息:
D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
D-Bus not built with -rdynamic so unable to print a backtrace
Aborted
首先你需要通過下面命令生成缺失的 machine-id(譯者注:我一般是直接在容器啟動時掛載host上的machine-id):
dbus-uuidgen > /var/lib/dbus/machine-id
這樣以來,即使DBus守護進程沒有啟動,應用也能啟動
要在容器中啟動D-Bus守護進程,你需要運行下面命令
mkdir -p /var/run/dbus
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address
在 Centos 上則改為:
dbus-daemon --config-file=/etc/dbus-1/system.conf --print-address
現在守護進程運行起來了,你的應用也能用了. 輸出的結果類似於下面這樣:
unix:path=/var/run/dbus/system_bus_socket,guid=9cfabcc6f66027251e092e955d09e707