github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/docs/admin/puppet.md (about) 1 <!--[metadata]> 2 +++ 3 aliases = ["/engine/articles/puppet/"] 4 title = "Using Puppet" 5 description = "Installing and using Puppet" 6 keywords = ["puppet, installation, usage, docker, documentation"] 7 [menu.main] 8 parent = "engine_admin" 9 +++ 10 <![end-metadata]--> 11 12 # Using Puppet 13 14 > *Note:* Please note this is a community contributed installation path. The 15 > only `official` installation is using the 16 > [*Ubuntu*](../installation/linux/ubuntulinux.md) 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 Puppet from 22 [Puppet Labs](https://puppetlabs.com) . 23 24 The module also currently uses the official PPA so only works with 25 Ubuntu. 26 27 ## Installation 28 29 The module is available on the [Puppet 30 Forge](https://forge.puppetlabs.com/garethr/docker/) and can be 31 installed using the built-in module tool. 32 33 $ puppet module install garethr/docker 34 35 It can also be found on 36 [GitHub](https://github.com/garethr/garethr-docker) if you would rather 37 download the source. 38 39 ## Usage 40 41 The module provides a puppet class for installing Docker and two defined 42 types for managing images and containers. 43 44 ### Installation 45 46 include 'docker' 47 48 ### Images 49 50 The next step is probably to install a Docker image. For this, we have a 51 defined type which can be used like so: 52 53 docker::image { 'ubuntu': } 54 55 This is equivalent to running: 56 57 $ docker pull ubuntu 58 59 Note that it will only be downloaded if an image of that name does not 60 already exist. This is downloading a large binary so on first run can 61 take a while. For that reason this define turns off the default 5 minute 62 timeout for the exec type. Note that you can also remove images you no 63 longer need with: 64 65 docker::image { 'ubuntu': 66 ensure => 'absent', 67 } 68 69 ### Containers 70 71 Now you have an image where you can run commands within a container 72 managed by Docker. 73 74 docker::run { 'helloworld': 75 image => 'ubuntu', 76 command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', 77 } 78 79 This is equivalent to running the following command, but under upstart: 80 81 $ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done" 82 83 Run also contains a number of optional parameters: 84 85 docker::run { 'helloworld': 86 image => 'ubuntu', 87 command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"', 88 ports => ['4444', '4555'], 89 volumes => ['/var/lib/couchdb', '/var/log'], 90 volumes_from => '6446ea52fbc9', 91 memory_limit => 10485760, # bytes 92 username => 'example', 93 hostname => 'example.com', 94 env => ['FOO=BAR', 'FOO2=BAR2'], 95 dns => ['8.8.8.8', '8.8.4.4'], 96 } 97 98 > *Note:* 99 > The `ports`, `env`, `dns` and `volumes` attributes can be set with either a single 100 > string or as above with an array of values.