HashiCorp Packer is a single binary that builds machine images (AMIs, Azure images, Docker images, VMware templates and more) from one HCL template. The commands above install it on macOS, Windows, Ubuntu and CentOS. This guide updates those steps for current releases, then covers verification, plugin setup, useful environment variables and a first working build.
Mac
brew tap hashicorp/tap
brew install hashicorp/tap/packer
Windows
https://releases.hashicorp.com/packer/1.8.6/packer_1.8.6_windows_amd64.zip
Step 1 โ Download and Extract at c:/tools/packer
Step 2 โ Add โc:/tools/packerโ into env PATH variable

Ubuntu
$ wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
$ sudo apt update && sudo apt install packerCode language: PHP (php)
Centos
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
$ sudo yum -y install packerCode language: JavaScript (javascript)
Corrected and current install commands
The steps above work in general, but a few have aged. The Windows link is pinned to an old 1.8.x release, the Ubuntu steps assume gpg and wget are already installed, and the CentOS steps target a distribution whose releases have reached end of life. Use the versions below instead.
Ubuntu / Debian. Install the prerequisites first and add the architecture to the repository line, so the commands also work on ARM64 hosts:
sudo apt update && sudo apt install -y gpg wget lsb-release
wget -O- https://apt.releases.hashicorp.com/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install -y packerCode language: PHP (php)
RHEL, Rocky Linux, AlmaLinux (and CentOS Stream). Current releases use dnf, and yum is just an alias for it. The HashiCorp repository URL stays the same:
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo dnf install -y packerCode language: JavaScript (javascript)
On Fedora, replace the repo URL with https://rpm.releases.hashicorp.com/fedora/hashicorp.repo.
Windows. Don't hard-code 1.8.6. Get the latest windows_amd64 (or windows_arm64) zip from https://releases.hashicorp.com/packer/, extract packer.exe to C:\tools\packer and add that folder to the user or system Path. Windows paths use backslashes. If you use Chocolatey, this one command does the same job:
choco install packer -y
macOS. The Homebrew commands above are correct. Upgrade later with brew upgrade hashicorp/tap/packer.
Manual binary install on any Linux host
If you can't add package repositories, for example on minimal CI runners or air-gapped hosts, download the zip directly and check its checksum before you trust it:
PACKER_VERSION="x.y.z" # set to the latest version listed at releases.hashicorp.com/packer/
cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip
wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS
# Verify the download
grep linux_amd64 packer_${PACKER_VERSION}_SHA256SUMS | sha256sum -c -
unzip packer_${PACKER_VERSION}_linux_amd64.zip
sudo install -m 0755 packer /usr/local/bin/packerCode language: PHP (php)
sha256sum -c should print packer_x.y.z_linux_amd64.zip: OK. If it doesn't, delete the file and download it again.
Verify the installation
packer version
which packer # Linux/macOS
where packer # Windows (cmd)Code language: PHP (php)
packer version prints something like Packer v1.x.y. Running plain packer lists the subcommands: init, fmt, validate, build, inspect, plugins and others. Packer also supports shell tab completion:
packer -autocomplete-install # then restart your shellCode language: PHP (php)
Configuration: plugins and environment variables
Packer itself contains almost no builders. Recent releases no longer bundle the AWS, Azure, Docker, VMware and similar integrations. You declare them in a required_plugins block and download them with packer init. By default, plugins go to ~/.config/packer/plugins on Linux and macOS and to %APPDATA%\packer.d\plugins on Windows.
| Variable | Purpose |
|---|---|
PACKER_LOG=1 | Turns on detailed debug logging, which is essential when a build fails |
PACKER_LOG_PATH | Writes the debug log to a file instead of stderr |
PACKER_PLUGIN_PATH | Overrides the plugin directory, for example to use a shared or pre-seeded folder in CI |
PACKER_CACHE_DIR | Where downloaded ISOs and other artefacts are cached |
CHECKPOINT_DISABLE=1 | Turns off the HashiCorp version check call |
PKR_VAR_<name> | Sets the value of an input variable called <name> |
export PACKER_LOG=1
export PACKER_LOG_PATH=./packer-debug.log
packer plugins installed # list plugins already presentCode language: PHP (php)
Your first build: a Docker image
This template needs only Docker on the local machine, so it's the quickest way to test the whole workflow without cloud credentials. Save it as docker-ubuntu.pkr.hcl in an empty folder:
packer {
required_plugins {
docker = {
source = "github.com/hashicorp/docker"
version = "~> 1"
}
}
}
source "docker" "ubuntu" {
image = "ubuntu:24.04"
commit = true
}
build {
name = "first-build"
sources = ["source.docker.ubuntu"]
provisioner "shell" {
inline = [
"echo 'Built by Packer' > /etc/packer-info",
"cat /etc/packer-info"
]
}
post-processor "docker-tag" {
repository = "local/packer-ubuntu"
tags = ["v1"]
}
}Code language: JavaScript (javascript)
required_pluginspins the Docker plugin to any 1.x release.packer initreads this block.sourcesets where the build starts. Here that's a container fromubuntu:24.04, andcommit = truesaves the container as an image.provisioner "shell"runs commands inside the container. Real templates install packages and harden the image at this stage.post-processor "docker-tag"tags the result so it shows up indocker images.
packer init .downloads the Docker plugin.packer fmt .normalises the formatting of the HCL.packer validate .checks syntax and configuration. It printsThe configuration is valid.packer build .runs the build. The output ends withBuilds finishedand the image ID.docker run --rm local/packer-ubuntu:v1 cat /etc/packer-infoconfirms the change. It printsBuilt by Packer.
Note: For cloud images, switch to the matching plugin (for example github.com/hashicorp/amazon with an amazon-ebs source). The init, validate and build workflow stays the same. Supply credentials through environment variables or instance roles, never hard-code them in the template.
Common errors and fixes
| Symptom | Cause | Fix |
|---|---|---|
packer: command not found / 'packer' is not recognized | The binary's folder isn't on PATH | Add the folder to PATH and open a new terminal |
Running packer on RHEL/Fedora prints cracklib usage text | cracklib ships /usr/sbin/packer, which can come before /usr/bin on PATH, especially for root | Call /usr/bin/packer directly, create an alias, or reorder PATH |
Error: Missing plugins or Unknown source type | The plugin wasn't installed | Add a required_plugins block and run packer init . |
NO_PUBKEY during apt update | The keyring file is missing or wasn't created correctly | Run the gpg --dearmor step again and check the signed-by path |
| Plugin download fails in CI | Rate limiting or no internet access | Pre-seed plugins and point PACKER_PLUGIN_PATH at them, or cache the plugin directory |
Best practices
- Pin the Packer version in CI and pin plugin versions with
versionconstraints, so builds can be reproduced. - Run
packer fmt -check .andpacker validate .in pull-request pipelines before anybuild. - Keep secrets in
PKR_VAR_*environment variables or a secrets manager, and mark variablessensitive = trueso they're hidden in logs. - Store templates in Git next to your Terraform or Ansible code. Packer builds the image and the other tools deploy it.
- Clean temporary build resources such as security groups and keys. Packer removes them itself unless a build is interrupted.
Frequently asked questions
How do I check which version of Packer is installed?
Run packer version. It prints the installed version, and if update checks are enabled it also tells you when a newer release is available.
Why does Packer say a builder or source type is unknown?
Most builders now ship as separate plugins. Declare the plugin in a required_plugins block and run packer init . before you validate or build.
Should I use JSON or HCL templates?
Use HCL2 (.pkr.hcl). JSON templates still work but are legacy, and packer hcl2_upgrade can convert an existing JSON template to HCL.
How do I upgrade Packer?
Upgrade it with your package manager: brew upgrade hashicorp/tap/packer, sudo apt install --only-upgrade packer, sudo dnf upgrade packer or choco upgrade packer. For manual installs, replace the binary with a newer one.
Where does Packer store plugins?
On Linux and macOS the default is ~/.config/packer/plugins, and on Windows it's %APPDATA%\packer.d\plugins. Set PACKER_PLUGIN_PATH to use a different directory.
Related tutorials
- More Infrastructure as Code tutorials
- More Linux tutorials
- How to Install and Configure pre-commit on macOS, Windows, and Linux: Complete Step-by-Step Guide
Iโm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals