我正在使用 chef-solo 在 docker 中运行社区 gerrit 食谱。
如果我在 Dockerfile 中运行说明书作为构建步骤,它会引发错误(检查日志)。但是,如果我运行图像并进入容器并运行相同的命令,它就可以正常工作。
知道发生了什么吗?它抱怨 sudo,但仍在继续并创建符号链接。'target_mode = nil' 应该不是问题,因为当我在容器内运行命令时它也会抱怨同样的事情,但工作正常。它最终抱怨 init.d 脚本没有意义。
chef-solo 作为构建步骤:
RUN chef-solo --log_level debug -c /resources/solo.rb -j /resources/node.json
日志:
[ :08+01:00] INFO: Processing ruby_block[gerrit-init] action run (gerrit::default line 225)
sudo: sorry, you must have a tty to run sudo
[ :08+01:00] INFO: /opt/gerrit/war/gerrit-2.7.war exist....initailizing gerrit
[ :08+01:00] INFO: ruby_block[gerrit-init] called
[ :08+01:00] INFO: Processing link[/etc/init.d/gerrit] action create (gerrit::default line 240)
[ :08+01:00] DEBUG: link[/etc/init.d/gerrit] created symbolic link from /etc/init.d/gerrit -> /opt/gerrit/install/bin/gerrit.sh
[ :08+01:00] INFO: link[/etc/init.d/gerrit] created
[ :08+01:00] DEBUG: found target_mode == nil, so no mode was specified on resource, not managing mode
[ :08+01:00] DEBUG: found target_uid == nil, so no owner was specified on resource, not managing owner
[ :08+01:00] DEBUG: found target_gid == nil, so no group was specified on resource, not managing group
[ :08+01:00] INFO: Processing link[/etc/rc3.d/S90gerrit] action create (gerrit::default line 244)
[ :08+01:00] DEBUG: link[/etc/rc3.d/S90gerrit] created symbolic link from /etc/rc3.d/S90gerrit -> ../init.d/gerrit
[ :08+01:00] INFO: link[/etc/rc3.d/S90gerrit] created
[ :08+01:00] DEBUG: found target_mode == nil, so no mode was specified on resource, not managing mode
[ :08+01:00] DEBUG: found target_uid == nil, so no owner was specified on resource, not managing owner
[ :08+01:00] DEBUG: found target_gid == nil, so no group was specified on resource, not managing group
[ :08+01:00] INFO: Processing service[gerrit] action enable (gerrit::default line 248)
[ :08+01:00] DEBUG: service[gerrit] supports status, running
================================================================================
Error executing action `enable` on resource 'service[gerrit]'
================================================================================
Chef::Exceptions::Service
-------------------------
service[gerrit]: unable to locate the init.d script!
Resource Declaration:
---------------------
# In /var/chef/cookbooks/gerrit/recipes/default.rb
248: service 'gerrit' do
249: supports :status => false, :restart => true, :reload => true
250: action [ :enable, :start ]
251: end
252:
Compiled Resource:
------------------
# Declared in /var/chef/cookbooks/gerrit/recipes/default.rb:248:in `from_file'
service("gerrit") do
action [:enable, :start]
supports {:status=>true, :restart=>true, :reload=>true}
retries 0
retry_delay 2
guard_interpreter :default
service_name "gerrit"
pattern "gerrit"
cookbook_name :gerrit
recipe_name "default"
end