雖然我可以登入運行容器甚至進入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 這樣做。