我使用廚師獨奏在docker上運行社區gerrit食譜。如何在碼頭集裝箱內運行gerrit cookbook?
如果我在Dockerfile中將Cookbook作爲構建步驟運行,它會引發錯誤(檢查日誌)。但是,如果我運行圖像並進入容器並運行相同的命令,它工作正常。
任何想法是怎麼回事?它抱怨sudo,但繼續並創造象徵性的聯繫。 'target_mode = nil'應該不是問題,因爲它在容器中運行命令時也抱怨同樣的事情,但工作正常。它最終抱怨init.d腳本沒有意義。
廚師獨奏作爲構建步驟:
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
有趣。你是說在構建Dockerfile的時候,它是在單一進程上運行的,當容器啓動時它可以有多個進程?我當然不會使用像supervisord這樣的花式東西。當我在正在運行的容器中運行chef-solo命令時,我沒有遇到任何問題。 – 2014-09-27 09:21:27
@SushanGhimire不完全。我在說,你不能認爲supervisord是安裝並運行的,用你的廚師獨奏來解釋你的錯誤開始一個不存在的服務。沒有任何東西可以阻止你像supervisord或runit那樣明確的進程管理器,但它需要更多的docker配置。從我讀到的新的「廚師初始化」過程旨在瞭解這個受限制的環境,以便廚師資源按照我們預期的那樣運行。 – 2014-09-27 19:56:25