github.com/slene/docker@v1.8.0-rc1/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. The only 15 > `official` installation is using the 16 > [*Ubuntu*](/installation/ubuntulinux) installation 17 > path. This version may sometimes be out of date. 18 19 ## Requirements 20 21 To use this guide you'll need a working installation of 22 [Chef](http://www.getchef.com/). This cookbook supports a variety of 23 operating systems. 24 25 ## Installation 26 27 The cookbook is available on the [Chef Community 28 Site](http://community.opscode.com/cookbooks/docker) and can be 29 installed using your favorite cookbook dependency manager. 30 31 The source can be found on 32 [GitHub](https://github.com/bflad/chef-docker). 33 34 ## Usage 35 36 The cookbook provides recipes for installing Docker, configuring init 37 for Docker, and resources for managing images and containers. It 38 supports almost all Docker functionality. 39 40 ### Installation 41 42 include_recipe 'docker' 43 44 ### Images 45 46 The next step is to pull a Docker image. For this, we have a resource: 47 48 docker_image 'samalba/docker-registry' 49 50 This is equivalent to running: 51 52 $ docker pull samalba/docker-registry 53 54 There are attributes available to control how long the cookbook will 55 allow for downloading (5 minute default). 56 57 To remove images you no longer need: 58 59 docker_image 'samalba/docker-registry' do 60 action :remove 61 end 62 63 ### Containers 64 65 Now you have an image where you can run commands within a container 66 managed by Docker. 67 68 docker_container 'samalba/docker-registry' do 69 detach true 70 port '5000:5000' 71 env 'SETTINGS_FLAVOR=local' 72 volume '/mnt/docker:/docker-storage' 73 end 74 75 This is equivalent to running the following command, but under upstart: 76 77 $ docker run --detach=true --publish='5000:5000' --env='SETTINGS_FLAVOR=local' --volume='/mnt/docker:/docker-storage' samalba/docker-registry 78 79 The resources will accept a single string or an array of values for any 80 Docker flags that allow multiple values.