我正在尝试使用opswork部署docker但设置失败。日志复制如下。
+================================================================================+
+Error Resolving Cookbooks for Run List:+
+================================================================================+
+Missing Cookbooks:+
+------------------+
+No such cookbook: docker+
+Expanded Run List:+
+------------------+
+* cookbook_sr::install+
+* cookbook_sr::docker-deploy+
+Platform:+
+---------+
我的食谱是,
1)install.rb
case node[:platform]
when "ubuntu","debian"
package "docker.io" do
action :install
end
when 'centos','redhat','fedora','amazon'
package "docker" do
action :install
end
end
service "docker" do
action :start
end
2)docker-deploy.rb
include_recipe 'deploy'
node[:deploy].each do |application, deploy|
if node[:opsworks][:instance][:layers].first != deploy[:environment_variables][:layer]
Chef::Log.debug("Skipping deploy::docker application #{application} as it is not deployed to this layer")
next
end
opsworks_deploy_dir do
user deploy[:user]
group deploy[:group]
path deploy[:deploy_to]
end
opsworks_deploy do
deploy_data deploy
app application
end
bash "docker-cleanup" do
user "root"
code <<-EOH
if docker ps | grep #{deploy[:application]};
then
docker stop #{deploy[:application]}
sleep 3
docker rm #{deploy[:application]}
sleep 3
fi
if docker images | grep #{deploy[:application]};
then
docker rmi #{deploy[:application]}
fi
EOH
end
bash "docker-build" do
user "root"
cwd "#{deploy[:deploy_to]}/current"
code <<-EOH
docker build -t=#{deploy[:application]} . > #{deploy[:application]}-docker.out
EOH
end
dockerenvs = " "
deploy[:environment_variables].each do |key, value|
dockerenvs=dockerenvs+" -e "+key+"="+value
end
bash "docker-run" do
user "root"
cwd "#{deploy[:deploy_to]}/current"
code <<-EOH
docker run #{dockerenvs} -p #{node[:opsworks][:instance][:private_ip]}:#{deploy[:environment_variables][:service_port]}:#{deploy[:environment_variables][:container_port]} --name #{deploy[:application]} -d #{deploy[:application]}
EOH
end
end
3)metadata.rb
name "creditcard_docker"
maintainer "xxxx"
maintainer_email "contact@xxxx.com"
license "Apache 2.0"
description "AWS opsworks docker"
version "1.0"
depends 'docker', '~> 2.0'
我的泊坞窗图层配置为
setup: cookbook_sr::install
deploy: cookbook_sr::docker-deploy
知道如何设置它(厨师12),还是有任何教程要遵循?
答案 0 :(得分:1)
这应该是对你的问题的评论而不是答案(但我的观点太少了)。
您是否尝试过用docker cookbook创建Berksfile?
source 'https://supermarket.chef.io'
metadata
或
source 'https://supermarket.chef.io'
cookbook "docker"