docker 中的 systemctl 错误“无法连接到总线:没有这样的文件或目录”

2024-03-01

我在用Ubuntu-16.04图像与docker在本地测试我的食谱。在做的同时kitchen converge,我收到以下错误。我想通了systemctl无法正常工作。有人可以帮我解决这个问题吗OR还有其他方法可以实现同样的目的吗?

 [2017-11-30T15:22:30+00:00] INFO: Running queued delayed notifications before re-raising exception

 Running handlers:
   [2017-11-30T15:22:30+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2017-11-30T15:22:30+00:00] ERROR: Exception handlers complete
   Chef Client failed. 9 resources updated in 06 seconds
   [2017-11-30T15:22:30+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2017-11-30T15:22:30+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2017-11-30T15:22:30+00:00] ERROR: envoy_auth_apps_setup[default-service] (envoy_auth_apps::_default line 1) had an error: Chef::Exceptions::MultipleFailures: Multiple failures occurred:
   * Mixlib::ShellOut::ShellCommandFailed occurred in chef run: execute[systemctl daemon-reload] (/tmp/kitchen/cache/cookbooks/envoy_auth_apps/resources/setup.rb line 133) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
   ---- Begin output of systemctl daemon-reload ----
   STDOUT:
   STDERR: Failed to connect to bus: No such file or directory
   ---- End output of systemctl daemon-reload ----
   Ran systemctl daemon-reload returned 1
   * Mixlib::ShellOut::ShellCommandFailed occurred in delayed notification: service[envoy] (/tmp/kitchen/cache/cookbooks/envoy_auth_apps/resources/setup.rb line 194) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
   ---- Begin output of /bin/systemctl --system restart envoy ----
   STDOUT:
   STDERR: Failed to connect to bus: No such file or directory
   ---- End output of /bin/systemctl --system restart envoy ----
   Ran /bin/systemctl --system restart envoy returned 1

   [2017-11-30T15:22:30+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
 >>>>>> ------Exception-------
 >>>>>> Class: Kitchen::ActionFailed
 >>>>>> Message: 1 actions failed.
 >>>>>>     Converge failed on instance <default-ubuntu>.  Please see .kitchen/logs/default-ubuntu.log for more details
 >>>>>> ----------------------
 >>>>>> Please see .kitchen/logs/kitchen.log for more details
 >>>>>> Also try running `kitchen diagnose --all` for configuration

这是我的.kitchen.yml

---

driver:
  name: docker
  binary: /usr/local/bin/docker
  use_sudo: false
  network:
    - ["public_network", "bridge: 'en0: Wi-Fi (AirPort)'"]

provisioner:
  name: chef_zero
  require_chef_omnibus: "12.21.14"
  environments_path: test/integration/environments
  nodes_path: test/integration/nodes
  data_bags_path: test/integration/data_bags
  client_rb:
    environment: development

verifier:
  name: inspec

platforms:
  - name: ubuntu
    driver_config:
      image: ubuntu:xenial
      platform: ubuntu
#     provision_command:
#       - apt-get -y install dbus

suites:
  - name: default
    run_list:
#   - recipe[base_app]
        - recipe[envoy_auth_apps::_default]
    verifier:
      inspec_tests:
        - test/integration/default
attributes:
  nameserver:
    domain_name: 'kitchen.xyz.io'
  envoy_auth_apps:
    consul_client_enabled: false

通常docker不支持systemd容器中的服务,但您可以使用特殊的ubuntu系统 https://hub.docker.com/r/solita/ubuntu-systemd/带有一些额外主机配置的图像。请注意,这张图片不推荐在生产中运行。

首先,您需要设置主机才能运行此映像:

docker run --rm --privileged -v /:/host solita/ubuntu-systemd setup

然后,您将能够运行容器systemd(添加必要的安装和标志):

docker run -d --name systemd --security-opt seccomp=unconfined \
 --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
 -t solita/ubuntu-systemd
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

docker 中的 systemctl 错误“无法连接到总线:没有这样的文件或目录” 的相关文章

随机推荐