$ sudo puppet module install garethr-docker
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
|--- garethr-docker (v4.1.1)
|-- puppetlabs-apt (v2.1.1)
|-- puppetlabs-stdlib (v4.9.0)
|-- stahnma-epel (v1.1.1)
include 'docker'
docker::image { 'ubuntu':
image_tag => 'trusty',
}
include 'docker'
-
By default, this sets up the docker hosted repository if necessary for our OS, and installs the docker package and on Ubuntu, any required Kernel extensions.
docker::image { 'ubuntu':
image_tag => 'trusty'
}
-
The image tags is equivalent to running docker pull -t="trusty" ubuntu.
-
Note that the image will only install if an image of that name does not already exist.
-
Let's apply the puppet manifest (/etc/puppet/manifests/docker_example.pp) in order to get docker installed on our puppet master:
$ sudo puppet apply site.pp
...
Notice: Finished catalog run in 46.40 seconds
$ sudo docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu trusty 91e54dfb1179 3 weeks ago 188.4 MB
docker::run { 'helloworld':
image => 'ubuntu',
command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
}
The above code snippet is equivalent to running the following:
docker run -d base /bin/sh -c "while true; do echo hello world; sleep 1; done"
This will launch a Docker container.