我正在使用带有 docker 的 Ubuntu-16.04 图片来测试我本地的食谱。在执行kitchen converge
时,我收到以下错误。我发现systemctl
无法正常工作。有人可以帮我解决这个问题或任何其他方式来实现同样的目的吗?
[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
答案 0 :(得分:3)
通常,docker不支持容器中的systemd
服务,但您可以使用特殊的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
答案 1 :(得分:2)
kitchen-docker
并未真正设置为与systemd一起使用。我建议改用kitchen-dokken
,这很容易设置。
答案 2 :(得分:0)
是的,还有另一种方法可以达到同样的效果!您可以尝试将标准systemd systemctl替换为https://github.com/gdraheim/docker-systemctl-replacement ...虽然它在令人惊讶的环境中工作,但到目前为止尚未对厨房进行测试。如果您试一试,请提供一些反馈。