How Do You Deploy Docker to Ubuntu Linux Servers Using Puppet?

Problem scenario
You want to deploy Docker to Ubuntu Linux using Puppet.  How do you write a manifest to install Docker an Ubuntu server?

This solution demonstrates transferring a file with Puppet.  

1.  Install Puppet master on an Ubuntu Server.  See this link if you want directions.
2.  Install Puppet agent on a different Ubuntu server.  See this link if you want directions.
3.  On the Puppet Master server, run this command (taken from this link):

puppet module install puppetlabs-docker_platform --version 2.2.1

4.  On the Puppet Master server, go to /etc/puppet/module/docker/.  Create a directory named "files".

5.  Still on the Puppet Master server, in the "files" directory, create a file named "" with the following content:

apt-get update
apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
echo 'deb trusty main' >> /etc/apt/sources.list.d/docker.list
apt-get update
apt-cache policy docker-engine
apt-get --assume-yes install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get --assume-yes install docker-engine
sudo service docker start
sudo groupadd docker
sudo usermod -aG docker ubuntu
docker run hello-world

6.  Still on the Puppet master server, go to /etc/puppet/manifests/.  Modify site.pp to have these stanzas:

file { '/tmp/':
   mode => '0644',
   source => 'puppet:///modules/docker/',
exec { 'install_docker':
    command => "/bin/bash /tmp/"

7.  On the Puppet Agent server, run this:

puppet agent -t -d

Leave a comment

Your email address will not be published. Required fields are marked *