I am trying to build a docker image that is provisioned with chef. It works for me with the following Dockerfile and chef recipe.
#Dockerfile
FROM centos:7
RUN yum install -y wget
RUN wget https://packages.chef.io/stable/el/7/chefdk-0.13.21-1.el7.x86_64.rpm
RUN yum install -y chefdk-0.13.21-1.el7.x86_64.rpm
COPY cookbooks cookbooks
RUN cd cookbooks/hs_price_verification && berks install && berks vendor cookbooks && chef-client -z --override-runlist hs_price_verification
#default.rb
include_recipe 'git'
package 'yum-utils'
execute 'yum --enablerepo=base clean metadata'
execute 'yum update -y || true'
execute 'yum-config-manager --enable cr'
domain=node['domainsname']
However if I move chef-client command to its own RUN line in the Dockerfile
...
RUN cd cookbooks/hs_price_verification && berks install && berks vendor cookbooks
RUN chef-client -z --override-runlist hs_price_verification
I get an error
================================================================================
Error Resolving Cookbooks for Run List:
================================================================================
Missing Cookbooks:
------------------
No such cookbook: git
Its like the results of 'berks install && berks vendor cookbooks' is on available on the same line of the Dockerfile and when I move the command the 'cache' is lost.
Can anyone explain?