【问题标题】:How to run dockerfile on chef-client如何在厨师客户端上运行 dockerfile
【发布时间】:2016-10-03 20:51:29
【问题描述】:

我在手动使用 docker 方面做得很好。我想使用厨师实现docker。作为厨师的初学者,我编写了一个示例 docker-file,它将在 centos:7 上安装 httpd 服务。

我的 docker 文件位于 Cookbook>docker>default>Dockerfile

在我的食谱中,我编写了一个命令来在 chef-client 上执行 Dockerfile。当我在客户端上运行(命令chef-client -r recipe[docker::testing])时出现错误。

我有两个问题

  1. 我是否遵循流程,例如放置 docker 文件和编写配方。
  2. recipe 对 dockerfile 的实际作用

食谱:我的食谱位于 Cookbook>recipes>testing.rb

cookbook_file '/etc/Dockerfile' do
   source 'Dockerfile'
end

execute 'Dockerfile' do
  user "root"
  command 'docker build -t sample:latest .'
  action :run
end

Dockerfile:

FROM centos:6
MAINTAINER Kumar
RUN yum -y update
RUN YUM -y install httpd

错误:

Recipe Compile Error
================================================================================

Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe default for cookbook docker

请帮忙。

【问题讨论】:

  • 这个问题很难理解

标签: docker chef-infra


【解决方案1】:

很难跟随你。您引用的错误可能源于您食谱中的一句话

include_recipe "docker"

include_recipe "docker::default"

失败的原因是您的 docker 食谱没有名为 default 的食谱。

一旦这个问题得到解决,我建议您针对其他问题打开一个新问题。

【讨论】:

  • 不是include_recipe,而是-r 运行列表覆盖:)
  • 而且我觉得cookbook文件也放错地方了,应该是cookbooks/<name of cookbook>/files/Dockerfile
最近更新 更多