For creating puppet containers, first we need to download the Puppet packages from the docker hub.
You can use the command docker pull Image_name for that.
root@ubuntu:~# docker pull puppet/puppetserver
root@ubuntu:~# docker pull puppet/puppetdb
root@ubuntu:~# docker pull puppet/puppetdb-postgres
root@ubuntu:~# docker pull puppet/puppet-agent-ubuntu
Now that we have downloaded all required images, you can view it by running docker images command.
root@ubuntu:~# docker images
Before creating our Puppet container, we need to create a Docker network to add these Puppet containers as below.
root@ubuntu:~# docker network create puppet
Creating Puppet Master server:
We can create puppet server with the image "puppet/puppetserver" with name puppet in the puppet network with hostname "puppet-sample".
root@ubuntu:~# docker run --net puppet --name puppet --hostname puppet.sample puppet/puppetserver
Now we've our Puppet Server created and running, you can verify it as shown below:
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f4b9f456a4c2 puppet/puppetserver "dumb-init /docker-en" 3 minutes ago Up 3 minutes 8140/tcp puppet
Creating Puppet Client:
By running this command, you're creating another container as Puppet client with hostname Puppet-client-sample with the docker image puppet/puppet-agent-ubuntu agent.
You can either use this command to create the Puppet client or you can just use docker run --net puppet puppet/puppet-agent-ubuntu to built one. If you're running this command, with a onetime flag which means, Puppet exits after the first run.
root@ubuntu:~# docker run --net puppet --name puppet-client --hostname puppet-client-sample puppet/puppet-agent-ubuntu agent --verbose --no-daemonize --summarize
But if you're using this above command, then the container won't exit, It stays online and updates Puppet every 30 minutes based on the latest content from the Puppet Server. Now we've our Puppet server/Client running on our Docker.
root@ubuntu:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f29866a103b puppet/puppet-agent-ubuntu "/opt/puppetlabs/bin/" 8 minutes ago Up 8 minutes puppet-client
f4b9f456a4c2 puppet/puppetserver "dumb-init /docker-en" 13 minutes ago Up 13 minutes 8140/tcp puppet