我运行的是 Debian 9.4。hostname
作品。
$ sudo strace -f hostnamectl
...snipped...
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/dbus/system_bus_socket"}, 33) = -1 ENOENT (No such file or directory)
...
Failed to create bus connection: No such file or directory
更新:这里有更多信息:
$ sudo systemctl status dbus.service dbus.socket
Unit dbus.service could not be found.
Unit dbus.socket could not be found.
$ ps -p 1
PID TTY TIME CMD
1 ? 00:00:47 systemd
$ sudo systemctl list-unit-files --state=running
0 unit files listed.
$ sudo systemctl list-unit-files --state=enabled
...snipped...
26 unit files listed.
答案1
看起来像总线包裹丢失。
使用以下命令检查 dbus 软件包是否已安装:
$ sudo dpkg -l | grep dbus
ii dbus 1.10.26-0+deb9u1 amd64 simple interprocess messaging system (daemon and utilities)
ii libdbus-1-3:amd64 1.10.26-0+deb9u1 amd64 simple interprocess messaging system (library)
如果总线安装包后,您将得到如上所示的输出。
如果输出为空则总线包裹丢失。您可以使用以下命令安装该软件包:
$ sudo apt-get install dbus
安装包后,您可以检查状态:
$ sudo systemctl status dbus.service dbus.socket
● dbus.service - D-Bus System Message Bus
Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
Active: active (running) since Fri 2018-09-07 23:39:14 EDT; 10s ago
Docs: man:dbus-daemon(1)
Main PID: 451 (dbus-daemon)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/dbus.service
└─451 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
● dbus.socket - D-Bus System Message Bus Socket
Loaded: loaded (/lib/systemd/system/dbus.socket; static; vendor preset: enabled)
Active: active (running) since Fri 2018-09-07 23:39:14 EDT; 10s ago
Listen: /var/run/dbus/system_bus_socket (Stream)
答案2
我通过使用这些命令解决了,在centos7/8容器中,在ubuntu容器中也是:
dbus-uuidgen > /var/lib/dbus/machine-id
mkdir -p /var/run/dbus
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address
但随后又遇到了与 dbus 套接字拒绝连接相关的另一个错误。如果我取得进展,将继续发布。