Puppet module for managing docker
Перейти к файлу
Gareth Rushgrove f95cd8e784 Merge pull request #49 from specialunderwear/lxc_conf_upstart
It would be nice if upstart users could also make use of the lxc_conf pa...
2014-03-22 10:44:51 +00:00
manifests Use udef as default for execdriver because the -e option is not supported on all docker versions. 2014-03-19 17:15:56 +01:00
spec Added test for lxc_conf parameter 2014-03-20 16:35:43 +01:00
templates/etc cleanup spaces 2014-03-19 17:29:36 +01:00
tests initial commit 2013-05-06 22:21:57 +01:00
.editorconfig support consistent coding style across users 2014-01-23 19:15:57 +00:00
.fixtures.yml add a bunch of RedHat specific tests 2014-01-19 13:44:46 +00:00
.gitignore git ignores .bundle/ 2014-01-20 15:54:52 +00:00
.nodeset.yml add a centos 65 box to the integration tests 2014-01-19 12:35:04 +00:00
.prefabs.yml add a centos 65 box to the integration tests 2014-01-19 12:35:04 +00:00
.rspec better formating of the results output 2013-12-07 13:42:27 +00:00
.travis.yml travis test matrix excludes rvm 1.9.3 when puppet < 3.0 2014-01-20 15:54:51 +00:00
CONTRIBUTING.md travis test matrix includes rvm 2.0.0 when puppet >= 3.2 2014-01-20 15:54:51 +00:00
Gemfile added serverspec in for nicer integration testing 2014-01-19 19:44:51 +00:00
Gemfile.lock update dependencies for developmet 2014-03-01 09:13:16 +00:00
LICENSE initial commit 2013-05-06 22:21:57 +01:00
Modulefile bump version number 2014-03-01 13:17:37 +00:00
README.md allow to suppress epel on red hat distros 2014-01-19 22:19:31 +00:00
Rakefile don't always require rake tasks from optional gems 2013-12-21 11:33:45 +00:00

README.md

Puppet module for installing Docker from the official repository on Ubuntu or from EPEL on RedHat based distributions.

This module is also available on the Puppet Forge

BuildStatus

Usage

The module includes a single class:

include 'docker'

By default this sets up the docker hosted Apt repository and installs the lxc-docker package and the required Kernel.

If you don't want this module to mess about with your Kernel then you can disable this feature like so:

class { 'docker':
  manage_kernel => false,
}

If you want to configure your package sources independently, inform this module to not auto-include upstream sources:

class { 'docker':
  use_upstream_package_source => false,
}

By default the docker daemon will bind to a unix socket at /var/run/docker.sock. This can be changed, as well as binding to a tcp socket if required.

class { 'docker':
  tcp_bind    => 'tcp://127.0.0.1:4243',
  socket_bind => 'unix:///var/run/docker.sock',
}

Unless specified this installs the latest version of docker from the lxc-docker package. However if you want to specify a specific version you can do so:

class { 'docker':
  version => '0.5.5',
}

In some cases dns resolution won't work well in the container unless you give a dns server to the docker daemon like this:

class { 'docker':
  dns => '8.8.8.8',
}

Images

The next step is probably to install a docker image, for this we have a defined type which can be used like so:

docker::image { 'base': }

This is equivalent to running docker pull base. This is downloading a large binary so on first run can take a while. For that reason this define turns off the default 5 minute timeout for exec. Takes an optional parameter for installing image tags that is the equivalent to running docker pull -t="precise" ubuntu:

docker::image { 'ubuntu':
  image_tag => 'precise'
}

Note: images will only install if an image of that name does not already exist.

You can also remove images you no longer need with:

docker::image { 'base':
  ensure => 'absent'
}

docker::image { 'ubuntu':
  ensure    => 'absent',
  image_tag => 'precise'
}

Containers

Now you have an image you can run commands within a container managed by docker.

docker::run { 'helloworld':
  image   => 'base',
  command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
}

This is equivalent to running the following under upstart:

docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done"

Run also contains a number of optional parameters:

docker::run { 'helloworld':
  image           => 'base',
  command         => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
  ports           => ['4444', '4555'],
  links           => ['mysql:db'],
  use_name        => true,
  volumes         => ['/var/lib/couchdb', '/var/log'],
  volumes_from    => '6446ea52fbc9',
  memory_limit    => 10485760, # bytes 
  username        => 'example',
  hostname        => 'example.com',
  env             => ['FOO=BAR', 'FOO2=BAR2'],
  dns             => ['8.8.8.8', '8.8.4.4'],
  restart_service => true,
}

Ports, env, dns and volumes can be set with either a single string or as above with an array of values.

To use an image tag just append the tag name to the image name separated by a semicolon:

docker::run { 'helloworld':
  image   => 'ubuntu:precise',
  command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
}