github.com/feiyang21687/docker@v1.5.0/docs/sources/articles/puppet.md (about)

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