No reliable way to prevent service startup during build
chef-init has issues with services startups during the build process. Here is an example that will not work:
knife container docker init demo/tomcat -r 'recipe[tomcat]' -z -b
knife container docker build demo/tomcat -z -VV
This tries to start tomcat during the build phase. IMHO the build should run through without service starts/restarts and the resulting image should have an installed tomcat that will not start if the image is run.
Moreover the current service provider implementation seems buggy. If you try to fix this by modifying the fist-boot.json to simply run anything else the build process will still not succeed for most public recipes.
{
"run_list": [
"recipe[apt]",
"recipe[tomcat]"
],
"container_service": {
"tomcat6": {
"command": "top"
}
}
}
The build will still fail:
[2014-10-01T12:24:30+00:00] INFO: template[/etc/default/tomcat6] sending restart action to service[tomcat6] (delayed)
[2014-10-01T12:24:30+00:00] INFO: Processing service[tomcat6] action restart (/root/.chef/local-mode-cache/cache/cookbooks/tomcat/providers/instance.rb line 245)
[2014-10-01T12:24:30+00:00] INFO: Provider for service[tomcat6] has been replaced with Chef::Provider::ContainerService::Runit
[2014-10-01T12:24:30+00:00] INFO: Processing directory[/opt/chef/sv/tomcat6] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing directory[/opt/chef/service] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing file[/opt/chef/sv/tomcat6/down] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: file[/opt/chef/sv/tomcat6/down] created file /opt/chef/sv/tomcat6/down
[2014-10-01T12:24:30+00:00] INFO: Processing file[/opt/chef/sv/tomcat6/run] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing directory[/var/log/tomcat6] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing directory[/opt/chef/sv/tomcat6/log] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing file[/opt/chef/sv/tomcat6/log/run] action create (dynamically defined)
[2014-10-01T12:24:30+00:00] INFO: Processing link[/opt/chef/service/tomcat6] action create (dynamically defined)
[2014-10-01T12:24:37+00:00] INFO: Retrying execution of service[tomcat6], 3 attempt(s) left
...
To address your first point, that is a very opinionated point of view about how that instance should behave. I understand that is how you'd like the build to work but you are the first to request that specific behavior. I'll keep that in mind but unless I get more feedback I'm not going to change what has been the default behavior of Chef since its inception.
To address your second issue, I am not quite sure why that is happening. I'll take a closer look into that. can you let me know what version of knife-container and chef-init you are using?