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