无法获得 D-Bus 连接:不允许操作

无法获得 D-Bus 连接:不允许操作

虽然我可以登录运行容器甚至进入Asterisk控制台,如下所示,似乎也看不到该Asterisk服务的状态:

ubuntu@ip-172-31-14-19:~$ 
ubuntu@ip-172-31-14-19:~$ sudo docker exec -it 115ac4e433ff bin/bash
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
[root@ip-172-31-14-19 /]# 
[root@ip-172-31-14-19 /]# whoami
root
[root@ip-172-31-14-19 /]# 
[root@ip-172-31-14-19 /]# service asterisk status
Redirecting to /bin/systemctl status  asterisk.service
Failed to get D-Bus connection: Operation not permitted
[root@ip-172-31-14-19 /]# 
[root@ip-172-31-14-19 /]# asterisk -rvvv
Asterisk certified/11.6-cert17, Copyright (C) 1999 - 2013 Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk certified/11.6-cert17 currently running on ip-172-31-14-19 (pid = 1)
ip-172-31-14-19*CLI> 
ip-172-31-14-19*CLI> 

尝试与 一起运行exec,除此之外,这可能是事情容器是如何创建的?

来自码头工人容器在 AWS 上。

答案1

每个使用 SystemD 控制服务的操作系统都会发生这种情况。 “systemctl”命令的作用并不多——它只是使用 d-bus 与 systemd 守护进程对话。但在 docker 容器内没有这样的东西。

使用以下命令覆盖 systemctl 时可以避免此错误 https://github.com/gdraheim/docker-systemctl-replacement直接执行服务的 ExecStart / ExceStop 部分,而不是要求 systemd 这样做。

相关内容