Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在docker容器中运行gerrit cookbook?_Docker_Centos6_Gerrit_Chef Solo_Linux Containers - Fatal编程技术网

如何在docker容器中运行gerrit cookbook?

如何在docker容器中运行gerrit cookbook?,docker,centos6,gerrit,chef-solo,linux-containers,Docker,Centos6,Gerrit,Chef Solo,Linux Containers,我在docker用chef solo运行社区gerrit cookbook 如果我在Dockerfile中运行cookbook作为构建步骤,它会抛出一个错误(检查日志)。但是,如果我运行图像并进入容器并运行相同的命令,它就可以正常工作 知道发生了什么吗? 它抱怨sudo,但仍在继续,并创造了象征性的联系target_mode=nil'应该不是问题,因为当我在容器内运行命令时,它也会抱怨同样的事情,但工作正常。它最终抱怨init.d脚本没有意义 作为构建步骤的厨师独奏: RUN chef-solo

我在docker用chef solo运行社区gerrit cookbook

如果我在Dockerfile中运行cookbook作为构建步骤,它会抛出一个错误(检查日志)。但是,如果我运行图像并进入容器并运行相同的命令,它就可以正常工作

知道发生了什么吗? 它抱怨sudo,但仍在继续,并创造了象征性的联系target_mode=nil'应该不是问题,因为当我在容器内运行命令时,它也会抱怨同样的事情,但工作正常。它最终抱怨init.d脚本没有意义

作为构建步骤的厨师独奏:

RUN chef-solo --log_level debug -c /resources/solo.rb -j /resources/node.json
日志:


容器不是虚拟机,这意味着它们运行单个进程,并且没有运行进程管理器。这解释了为什么chef solo在创建服务资源时会遇到问题

我建议阅读chef为容器设计的一些新兴支持:


我并不假装一开始读起来很有道理。我还不确定chef是构建容器的最佳方法。

实际错误是
sudo:对不起,您必须有一个tty才能运行sudo
,由于安全原因,linux终端未分配,详细信息请参阅


默认情况下,Docker以root用户身份运行,不需要执行sudo。我正在运行的食谱创建了“gerrit”用户,这让我做了sudo。我删除了用户,并以root用户身份运行了所有内容。解决了

有趣。您是说在构建Dockerfile时,它在单个进程上运行,而当容器启动时,它可以有多个进程?我当然不会用像supervisord这样的花哨玩意儿。当我在一个正在运行的容器中运行chef solo命令时,我不会遇到任何问题。@SushanGhimire不太可能。我的意思是,您不能假设supervisord已安装并正在运行,解释您使用chef solo启动不存在的服务时的错误。没有什么可以阻止您显式地使用像supervisord或runit这样的流程管理器,但它需要更多的docker配置。从我所读到的内容来看,新的“chef init”流程旨在理解这个受限环境,以便chef资源按照我们预期的方式运行。
[ :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