Docker 17
引擎: 管理员指南 | Engine: Admin Guide

使用Chef(引擎) | Using Chef (Engine)

使用 Chef

注意:请注意,这是一个社区贡献的安装路径。

要求

要使用本指南,您需要 Chef 的工作安装。这本烹饪书支持各种操作系统。

安装

Cookbook可在 Chef Supermarket 实现,并可使用您最喜欢的食谱依赖管理器进行安装。

源可以在GitHub上找到。

用法

  • 添加depends 'docker', '~> 2.0'到你的食谱的 metadata.rb

  • 使用菜谱中的资源,就像使用核心厨师资源(文件,模板,目录,包等)一样。

docker_service 'default' do action [:create, :start] end docker_image 'busybox' do action :pull end docker_container 'an echo server' do repo 'busybox' port '1234:1234' command "nc -ll -p 1234 -e /bin/cat" end

入门

以下是拉取最新映像并运行带有暴露端口的容器的简单示例。

# Pull latest image docker_image 'nginx' do tag 'latest' action :pull end # Run container exposing ports docker_container 'my_nginx' do repo 'nginx' tag 'latest' port '80:80' binds [ '/some/local/files/:/etc/nginx/conf.d' ] host_name 'www' domain_name 'computers.biz' env 'FOO=bar' subscribes :redeploy, 'docker_image[nginx]' end

chef, installation, usage, docker, documentation