我正在尝试构建由厨师提供的docker镜像。它适用于以下Dockerfile和Chef食谱。
#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']
但是,如果我将Chef-client命令移到Dockerfile中自己的RUN行,
...
RUN cd cookbooks/hs_price_verification && berks install && berks vendor cookbooks
RUN chef-client -z --override-runlist hs_price_verification
我得到一个错误
================================================================================
Error Resolving Cookbooks for Run List:
================================================================================
Missing Cookbooks:
------------------
No such cookbook: git
就像“berks install && berks供应商食谱”的结果在Dockerfile的同一行上一样,当我移动命令时,“缓存”将丢失。
谁能解释?
最佳答案
Docker在自己的命令中运行每个RUN
行,这意味着前一行的cd
在那里无效。
关于docker - 向Chef配置Docker镜像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37188258/