github.com/vincentwoo/docker@v0.7.3-0.20160116130405-82401a4b13c0/docs/articles/chef.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Using Chef"
     4  description = "Installation and using Docker via Chef"
     5  keywords = ["chef, installation, usage, docker,  documentation"]
     6  [menu.main]
     7  parent = "smn_third_party"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # Using Chef
    12  
    13  > **Note**:
    14  > Please note this is a community contributed installation path.
    15  
    16  ## Requirements
    17  
    18  To use this guide you'll need a working installation of
    19  [Chef](https://www.chef.io/). This cookbook supports a variety of
    20  operating systems.
    21  
    22  ## Installation
    23  
    24  The cookbook is available on the [Chef Supermarket](https://supermarket.chef.io/cookbooks/docker) and can be
    25  installed using your favorite cookbook dependency manager.
    26  
    27  The source can be found on
    28  [GitHub](https://github.com/someara/chef-docker).
    29  
    30  Usage
    31  -----
    32  - Add ```depends 'docker', '~> 2.0'``` to your cookbook's metadata.rb
    33  - Use resources shipped in cookbook in a recipe, the same way you'd
    34    use core Chef resources (file, template, directory, package, etc).
    35  
    36  ```ruby
    37  docker_service 'default' do
    38    action [:create, :start]
    39  end
    40  
    41  docker_image 'busybox' do
    42    action :pull
    43  end
    44  
    45  docker_container 'an echo server' do
    46    repo 'busybox'
    47    port '1234:1234'
    48    command "nc -ll -p 1234 -e /bin/cat"
    49  end
    50  ```
    51  
    52  ## Getting Started
    53  Here's a quick example of pulling the latest image and running a
    54  container with exposed ports.
    55  
    56  ```ruby
    57  # Pull latest image
    58  docker_image 'nginx' do
    59    tag 'latest'
    60    action :pull
    61  end
    62  
    63  # Run container exposing ports
    64  docker_container 'my_nginx' do
    65    repo 'nginx'
    66    tag 'latest'
    67    port '80:80'
    68    binds [ '/some/local/files/:/etc/nginx/conf.d' ]
    69    host_name 'www'
    70    domain_name 'computers.biz'
    71    env 'FOO=bar'
    72    subscribes :redeploy, 'docker_image[nginx]'
    73  end
    74  ```