We want to create a chef recipe which can able to login to docker registry and pull some images. I have tried using docker_registry resource as mentioned here https://github.com/chef-cookbooks/docker#docker_registry.

my resource in recipe looks like

    docker_registry 'my local registry' do
       serveraddress 'https://xxxxxxxx.com/'
       username 'xxxx'
       password 'xxxxx'
    end

But this is failing as undefined method docker_registry.

    ERROR: Exception handlers complete
    Chef Client failed. 0 resources updated in 02 seconds
    FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
    FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    ERROR: undefined method `docker_registry' for cookbook:xxxxxxxx, recipe: xxxxx :Chef::Recipe
    FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Do we need to define any dependency in metadata.rb so that resource can be executed? what is the best way to login to docker registry using chef. Thanks Much for the help!

  • Do you really depend on docker cookbook within your cookbook ? – Tensibai Oct 11 at 13:17
  • no we are not dependent on it. we just want to login to docker registry so that we can able to pull docker images from our local registry. – DevOps Oct 11 at 13:52
  • When you want to use a resource from another cookbook, you need to depend on it, I highly suggest you follow the base tracks on learn.chef.io – Tensibai Oct 11 at 14:21
  • Right, I know we need to add dependency but I am wondering if we can able to do with some chef resource rather than adding several dependencies. – DevOps Oct 11 at 14:50
  • You can read the docker cookbook code you linked and reimplement it in your own cookbook as libraries or custom resource. – Tensibai Oct 11 at 14:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.