docker中的systemctl错误“无法连接到总线:没有这样的文件或目录" [英] systemctl error in docker 'Failed to connect to bus: No such file or directory'

查看:325
本文介绍了docker中的systemctl错误“无法连接到总线:没有这样的文件或目录"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Ubuntu-16.04 图片与 docker 一起在本地测试我的食谱.在进行厨房收敛时,出现以下错误.我发现 systemctl 无法正常工作.有人可以帮助我 OR 来解决同一问题吗?

I am using Ubuntu-16.04 image with docker to test my cookbook in local. While doing kitchen converge, I am getting the following error. I figured out systemctl is not working properly. Can someone please help me to fix this problem OR any other way to achieve the same thing?

 [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 服务,但是您可以使用特殊的

Normally docker doesn't support systemd services in container, but you can use a special ubuntu systemd image with some additional host configuration. Note that this image is not recommended to be run in production.

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

Firstly, you need to setup your host to be able to run this image:

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

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

Then, you'll be able to run containers with systemd (adding necessary mounts and flags):

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

这篇关于docker中的systemctl错误“无法连接到总线:没有这样的文件或目录"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆