github.com/slene/docker@v1.8.0-rc1/docs/articles/puppet.md (about)

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