jambit Toilet Paper 113

Machine images as code with Packer


Containers and deployables in PaaS (Platform as a Service) environments are okay, but sometimes you need or want to create machine images, e.g. for IaaS (Infrastructure as a Service) environments or to set up the PaaS environments mentioned above. And in best case independent of the respective virtualization environment or cloud. Moreover, the advantage of machine images is that they only have to be provisioned at the time of creation and can afterwards be started quickly.

So back to self-made shell scripts and handwork? No.


There is a tool from HashiCorp, the originators of Terraform, Vagrant, Vault etc..

Packer offers the possibility to define the machine image at first and in the following to create the images for different virtualization solutions and clouds. You don't have to reinvent the wheel, because Packer supports well-known provisioning tools like Chef, Ansible and others.

Components from Packer:

  • Templates are the configuration files (JSON) of Packer and describe one or more images.
  • Builders produce the images for one platform at a time.
  • e.g. Amazon EC2, Azure, Docker, Google Cloud, Vagrant, VirtualBox, VMWare, and many more.
  • Provisioners install and configure the respective image.
  • e.g. with Chef, Puppet, Ansible, Shell-Scripts, etc.
  • Artifact is the result of a builder (the generated machine image).
  • Post-Processors takes the created images and executes further tasks (e.g. push in Docker Registry).

All defined images are created with the following simple command:

packer build

The packer template creates an Amazon Machine Image (AMI) in AWS. In the build, the image is provisioned with Ansible.

Das Packer-Template erzeugt ein Amazon Machine Image (AMI) in AWS
Machine images as code with Packer

Cookie Settings

This website uses cookies to personalize content and ads, provide social media features, and analyze website traffic. In addition, information about your use of the website is shared with social media, advertising, and analytics partners. These partners may merge the information with other data that you have provided to them or that they have collected from you using the services.

For more information, please refer to our privacy policy. There you can also change your cookie settings later on.

contact icon

Contact us now