Installing and configuring chef into docker container

Hi, all

I’m trying to dockerize chef-server with CentOS 7. But I am getting

================================================================================
Recipe Compile Error in /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/default.rb
================================================================================

Chef::Exceptions::NoSuchResourceType
------------------------------------
Cannot find a resource for component_runit_supervisor on centos version 7.4.1708

Cookbook Trace:
---------------
  /var/opt/opscode/local-mode-cache/cookbooks/enterprise/recipes/runit.rb:28:in `from_file'
  /var/opt/opscode/local-mode-cache/cookbooks/private-chef/recipes/default.rb:108:in `from_file'

Relevant File Content:
----------------------
/var/opt/opscode/local-mode-cache/cookbooks/enterprise/recipes/runit.rb:

 21:  node.override['runit']['sv_bin']       = "#{install_path}/embedded/bin/sv"
 22:  node.override['runit']['svlogd_bin']   = "#{install_path}/embedded/bin/svlogd"
 23:  node.override['runit']['chpst_bin']    = "#{install_path}/embedded/bin/chpst"
 24:  node.override['runit']['service_dir']  = "#{install_path}/service"
 25:  node.override['runit']['sv_dir']       = "#{install_path}/sv"
 26:  node.override['runit']['lsb_init_dir'] = "#{install_path}/init"
 27:
 28>> component_runit_supervisor node['enterprise']['name'] do
 29:    ctl_name node[node['enterprise']['name']]['ctl_name'] ||
 30:             "#{node['enterprise']['name']}-ctl"
 31:    sysvinit_id node[node['enterprise']['name']]['sysvinit_id']
 32:    install_path node[node['enterprise']['name']]['install_path']
 33:  end
 34:

Platform:
---------
x86_64-linux

[2017-10-15T14:51:23+00:00] FATAL: Stacktrace dumped to /var/opt/opscode/local-mode-cache/chef-stacktrace.out
[2017-10-15T14:51:23+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-10-15T14:51:23+00:00] FATAL: Chef::Exceptions::NoSuchResourceType: Cannot find a resource for component_runit_supervisor on centos version 7.4.1708

Although I installed chef-server , runit , and supervisor, I getting same error message.

Could anyone help me out on this.

here’s my Dockerfile

----
FROM centos:latest

ADD rpms/chef-server-core-12.16.14-1.el7.x86_64.rpm /chef-server.rpm
ADD rpms/python-meld3-0.6.10-1.el7.x86_64.rpm /python-melds3.rpm
ADD rpms/supervisor-3.1.4-1.el7.noarch.rpm /supervisor.rpm
ADD rpms/python-setuptools-0.9.8-7.el7.noarch.rpm /python-setuptools.rpm
ADD rpms/runit-2.1.1-7.el7.centos.x86_64.rpm /runit.rpm

RUN yum install -y /python-setuptools.rpm
RUN yum install -y /python-melds3.rpm
RUN yum install -y /supervisor.rpm
RUN yum install -y /chef-server.rpm

RUN yum install -y /runit.rpm

RUN ln -sf /bin/true /sbin/initctl

ADD scripts/run.sh /usr/local/bin/
ADD scripts/chef-server-setup.sh /usr/local/bin/chef-server-setup.sh

CMD rsyslogd -n

VOLUME /root
VOLUME /var/log
VOLUME /opt
VOLUME /etc

RUN ["chmod", "+x", "/usr/local/bin/chef-server-setup.sh"]
RUN ["chmod", "+x", "/usr/local/bin/run.sh"]

CMD ["/usr/local/bin/chef-server-setup.sh"]
CMD ["/usr/local/bin/run.sh"]

EXPOSE 443
------

and here’s my scripts, respectively, chef-server-setup.sh, run.sh

----
#!/bin/bash

export PATH=/opt/opscode/bin:/opt/opscode/bin/embedded:$PATH


/opt/opscode/embedded/bin/runsvdir-start &
chef-server-ctl start

chef-server-ctl status

chef-server-ctl tail
----
#!/bin/sh

set -x
sysctl -wq kernel.shmmax=17179869184 # for postgres
sysctl -wq net.ipv6.conf.lo.disable_ipv6=0
/opt/opscode/embedded/bin/runsvdir-start &


chef-server-ctl reconfigure
chef-server-ctl user-create $FIRST_NAME $LAST_NAME user $USER_MAIL $PASSWORD --filename /chef.pem
chef-server-ctl org-create $USER $ORG_NAME --association_user $USER --filename /chef-validator.pem


chef-server-ctl tail
----

We super duper don’t support Chef Server inside Docker. You could definitely do it, but it wouldn’t be with the omnibus installers we release. Notably RabbitMQ really doesn’t like being inside a container. If you want to do this, you’ll have to (probably) build all the subcomponents yourself in a way that is more Docker-friendly.

(For those that want to dig deeper, RabbitMQ is very sensitive to hostname issues which Docker tends to screw up. There is nothing inherently impossible about Chef Server in Docker, it’s just a largely unexplored area with no docs that I know of and will probably not work with the defaults shipped in our installers)