Files
docker-docs/engine/admin/chef.md
Misty Stanley-Jones e3a3145cd9 Sync vnext-engine branch to docker/docker SHA 2f12d2808464dcfdf45e0920fd508ce0ff12bd29
This branch will contain forward-looking Engine-specific docs
and be the equivalent of docker/docker master for docs
2017-01-19 10:10:15 -08:00

1.6 KiB

description, keywords, redirect_from, title
description keywords redirect_from title
Installation and using Docker via Chef chef, installation, usage, docker, documentation
/engine/articles/chef/
Use Chef

Note

: Please note this is a community contributed installation path.

Requirements

To use this guide you'll need a working installation of Chef. This cookbook supports a variety of operating systems.

Installation

The cookbook is available on the Chef Supermarket and can be installed using your favorite cookbook dependency manager.

The source can be found on GitHub.

Usage

  • Add depends 'docker', '~> 2.0' to your cookbook's metadata.rb
  • Use resources shipped in cookbook in a recipe, the same way you'd use core Chef resources (file, template, directory, package, etc).
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

Getting Started

Here's a quick example of pulling the latest image and running a container with exposed ports.

# 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