Packer Fundamentals
Packer is a command-line tool that builds machine images from templates. You define a repeatable image build once, then use plugins to produce artifacts for platforms such as clouds, virtual machines, and containers.
itInfrastructure and operations | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Packer Fundamentals
Packer is a tool for turning an image recipe into a machine-image candidate. That sentence contains most of the plot. Instead of installing an operating system and dependencies during every deployment, you describe the work once in a template and move it into a controlled build stage. The result might be a cloud image, a virtual machine image, or a container image. It is not a deployment, a scheduler, or a tiny robot with a pager.
The recipe is called a template, and modern Packer templates use HCL. A template declares its plugins, inputs, sources, and builds. The source describes one target and its builder settings. The build chooses one or more sources and can add provisioners and post-processors. This sounds like paperwork because it is paperwork, but it is the useful sort: the paperwork explains how a temporary machine or container became an artifact.
A builder starts that temporary environment and produces the artifact. A provisioner changes the environment before capture, perhaps by installing packages or uploading files. A post-processor acts after the artifact exists. Each role has a boundary. Packer coordinates image creation, while another system tests, publishes, deploys, tracks, and eventually retires the image. Asking Packer to manage all of that is like asking the oven to run the restaurant.
The surprise is that a template is not the whole build. Base images move. Package repositories publish new packages. Plugin constraints can allow newer plugins. Scripts can read hidden environment state. The same unchanged HCL can therefore create a different result later. Control the inputs that matter, record their identifiers, and keep credentials out of the template. The template is the recipe, not the pantry, delivery van, or security desk.
The practical loop is `packer init`, `packer fmt`, `packer validate`, and `packer build`. Initialization installs declared plugins. Formatting normalizes HCL. Validation checks syntax and configuration. Building creates the candidate. None of this proves that the artifact boots, the application works, or security policy is met. That proof begins after Packer succeeds, which is inconvenient only if you were hoping a green command line could be a test suite.
Read the Intro for the full component flow and responsibility boundary. Use Slides when you need the relationships at a glance. Keep the Cheatsheet nearby for command controls and failure triage. The Quiz is a quick check that the roles have not quietly swapped hats. Then use the Reference links to choose the target-platform builder and turn this controlled workshop into a delivery path.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://developer.hashicorp.com/packer/docs
Supports
- Packer creates machine images from configuration
- Golden images as a common organizational use case
- Templates, CLI, plugins, integrations, and HCP Packer documentation map
- https://developer.hashicorp.com/packer/docs/intro
Supports
- Packer purpose and machine-image workflow
- Multiple target-platform image creation
- Separation between image creation and image management
- https://developer.hashicorp.com/packer/docs/terminology
Supports
- Definitions of artifact, build, builder, command, data source, post-processor, provisioner, and template
- Templates can define several builds and image targets
- https://developer.hashicorp.com/packer/docs/templates/hcl_templates
Supports
- HCL template purpose
- Source and build relationship
- Supported HCL template filename forms
- Template arguments, blocks, expressions, variables, locals, and data sources
- Directory and single-file build behavior
- https://developer.hashicorp.com/packer/docs/templates/hcl_templates/syntax
Supports
- Native HCL syntax and configuration structure
- Block, argument, and expression foundations used by Packer templates
- https://developer.hashicorp.com/packer/docs/plugins
Supports
- Built-in and external plugin model
- Plugins as separate applications that extend Packer
- Builder, data-source, provisioner, and post-processor plugin roles
- Plugin installation and third-party plugin review considerations
- https://developer.hashicorp.com/packer/docs/builders
Supports
- Builders create machines and images
- Installed integrations provide platform-specific builders
- File, null, custom, and community builder categories
- https://developer.hashicorp.com/packer/docs/provisioners
Supports
- Provisioners install and configure software before image capture
- Built-in shell, file, PowerShell, Windows restart, shell-local, and breakpoint provisioners
- https://developer.hashicorp.com/packer/docs/post-processors
Supports
- Post-processors run after builders and provisioners
- Optional artifact upload and repackaging uses
- https://developer.hashicorp.com/packer/docs/commands/init
Supports
- Initialization installs required plugins for HCL templates
- Required plugin blocks, repeated initialization, and upgrade behavior
- Template and variable filename conventions
- Need to vet third-party plugins
- https://developer.hashicorp.com/packer/docs/commands/validate
Supports
- Validation checks syntax and configuration
- Success and failure exit behavior
- Syntax-only, variable-file, only, and except controls
- Validation can evaluate external data sources when requested
- https://developer.hashicorp.com/packer/docs/commands/inspect
Supports
- Inspect lists template variables, builders, provisioners, and execution order
- Inspect checks syntax but does not replace configuration validation
- https://developer.hashicorp.com/packer/docs/commands
Supports
- CLI subcommand model
- Machine-readable output availability and format
- Build selection controls
- https://developer.hashicorp.com/packer/tutorials/docker-get-started/docker-get-started-build-image
Supports
- Complete HCL template with required plugin, Docker source, and build block
- Source labels and build source references
- Init, format, validate, and build sequence
- Artifact management remains outside Packer after the build
- Docker builder creates and commits a Docker image
- https://developer.hashicorp.com/packer/integrations
Supports
- Platform-specific plugin and component documentation
- Official and community integration discovery
- https://docs.docker.com/reference/cli/docker/container/run/
Supports
- Docker run starts a container from an image
- Container command output can inspect files in the built image
- https://www.hashicorp.com/en/blog/hashicorp-adopts-business-source-license
Supports
- HashiCorp changed future product releases to Business Source License 1.1
- Business Source License 1.1 is source-available with commercial-use conditions
- https://developer.hashicorp.com/hcp/docs/hcp/admin/billing/pricing-definitions
Supports
- HCP Packer tracks image metadata in its registry
- HCP Packer image buckets and image requests use usage-based billing
- https://docs.aws.amazon.com/imagebuilder/latest/userguide/what-is-image-builder.html
Supports
- EC2 Image Builder creates customized server and container images
- EC2 Image Builder has no separate service charge while related AWS resources can incur costs
- https://azure.microsoft.com/en-us/pricing/details/image-builder/
Supports
- Azure VM Image Builder creates Linux and Windows images
- Azure Image Builder is free while underlying compute, storage, and network resources are charged
- https://docs.ansible.com/projects/builder/en/latest/index.html
Supports
- Ansible Builder creates customized containerized execution environments
- Execution-environment definitions select base images and dependency versions
- https://github.com/ansible/ansible-builder
Supports
- Ansible Builder is licensed under Apache License 2.0
- https://www.hashicorp.com/en/about/origin-story
Supports
- Packer 0.1 was released in June 2013
- https://www.hashicorp.com/ar/blog/packer-1-0
Supports
- Packer 1.0 was released in April 2017
- Packer 1.0 marked a stability and backwards-compatibility milestone
- https://www.hashicorp.com/en/blog/announcing-hashicorp-packer-1-5-with-hcl2-support
Supports
- Packer 1.5 added HCL2 template support in February 2020
- https://developer.hashicorp.com/packer/guides/1.7-plugin-upgrade
Supports
- Packer 1.7 split plugin development interfaces into the Packer Plugin SDK
- https://www.hashicorp.com/en/blog/announcing-hcp-packer
Supports
- HCP Packer was announced in June 2021
- HCP Packer tracks metadata between image creation and deployment
- https://www.hashicorp.com/en/blog/predictable-plugin-loading-in-packer-1-11
Supports
- Packer 1.11 introduced predictable plugin loading in March 2024
- Plugin binaries require the plugin directory and accompanying SHA256SUM files
- https://developer.hashicorp.com/packer/docs/release-notes/v1_12
Supports
- Packer 1.12 added HCP Packer SBOM association support in January 2025
- https://developer.hashicorp.com/packer/docs/plugins
Supports
- HashiCorp moved many maintained Packer plugins to its official release site beginning August 2025
- https://github.com/hashicorp/packer/issues/8792
Supports
- A Packer build can report failure while an AMI has been created
- Failed runs need artifact reconciliation before automated retry or promotion
