One advantage of using Puppet for building Docker images is you are removed from the need to have a single Dockerfile per image.
Meaning a single repository of Puppet code can be used to describe multiple images.
This makes ensuring all images use (for example) the same repositories or same hardening scripts much easier to enforce. Change code in one place and rebuild multiple images.
Describing multiple images in Puppet is done using the existing node resource in your manifest. For instance:
node 'node1' {
webserver { 'hello node 1': }
}
node 'node2' {
webserver { 'hello node 2': }
}
You can then select which image to build when running the build command, by explicitly passing the image-name.
puppet docker build --image-name puppet/node1
The match for the node resource in the Puppet code is done without the repository name, in this case the puppet/before node1.
Note that you may want different metadata for different images.
image_build will attempt to detect additional metadata in the metadata folder, and will merge items from metadata/metadata.yaml with node specific metadata, for instance from metadata/node1.yaml