(Last Updated On: April 19, 2019)

In this guide, we will show you how you can easily install the Latest Packer on Linux / FreeBSD / macOS. Packer is an open source tool for creating identical machine images for multiple platforms from a single source configuration.

Packer is a cross-platform command-line and lightweight application capable of generating and highly machine images for multiple platforms in parallel. Supported builders include Amazon EC2, Openstack, Azure, DigitalOcean, Docker, LXC, QEMU, Parallels, VMware, Vagrant, VirtualBox, File, Google Cloud e.t.c.

Check Packer use cases if you’re new to it and trying to figure out how you benefit from this tool.

What is Packer Machine Image?

A machine image is a single static unit that contains a pre-configured operating system and installed software which is used to quickly create new running machines. Machine image formats change for each platform. Some examples include AMIs for EC2, VMDK/VMX files for VMware, OVF exports for VirtualBox, and many others.

How to Install Packer on Linux / FreeBSD / macOS / Windows

Packer can be installed from a precompiled binary or from source. The easy and recommended method for all users is the binary installation method.

First, check the latest release of Packer on the Downloads page. Then download the recent version for your platform. As of this article update, the most recent release is version 1.4.0.

How to Install Packer on Linux

Save packer version to a variable.

export PACKER_RELEASE="1.4.0"

Then download the latest version using wget command, extract and cop packer binary file to /usr/local/bin directory.

For 64-bit CPU system:

cd /tmp/
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_linux_amd64.zip
unzip packer_${PACKER_RELEASE}_linux_amd64.zip
sudo mv packer /usr/local/bin

If you’re running a 32 bit CPU:

cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_linux_386.zip
unzip packer_${PACKER_RELEASE}_linux_386.zip
sudo mv packer /usr/local/bin

For ARM CPU architecture:

cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_linux_arm.zip
unzip packer_${PACKER_RELEASE}_linux_arm.zip
sudo mv packer /usr/local/bin

How to Install Packer on FreeBSD

Download the version for FreeBSD system.

export PACKER_RELEASE="1.4.0"

For 64-bit CPU system:

cd /tmp/
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_freebsd_amd64.zip
unzip packer_${PACKER_RELEASE}_freebsd_amd64.zip
sudo mv packer /usr/local/bin

If you’re running a 32 bit CPU:

cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_freebsd_386.zip
unzip packer_${PACKER_RELEASE}_freebsd_386.zip
sudo mv packer /usr/local/bin

For ARM CPU architecture:

cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_freebsd_arm.zip
unzip packer_${PACKER_RELEASE}_freebsd_arm.zip
sudo mv packer /usr/local/bin

How to Install Packer on macOS

Download the version for macOS system.

export PACKER_RELEASE="1.4.0"

For 64-bit CPU system:

cd /tmp/
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_darwin_amd64.zip
unzip packer_${PACKER_RELEASE}_darwin_amd64.zip
sudo mv packer /usr/local/bin

If you’re running a 32 bit CPU:

cd /tmp
wget https://releases.hashicorp.com/packer/${PACKER_RELEASE}/packer_${PACKER_RELEASE}_darwin_386.zip
unzip packer_${PACKER_RELEASE}_darwin_386.zip
sudo mv packer /usr/local/bin

After installing Packer, verify the installation is working by checking that the packer is available:

$ packer
Usage: packer [--version] [--help] <command> [<args>]

Available commands are:
    build       build image(s) from template
    fix         fixes templates from old versions of packer
    inspect     see components of a template
    validate    check that a template is valid
    version     Prints the Packer version

How to Install Packer on Windows

Download and install Scoop Windows command line installer:

How to install Applications from Windows command line

Once installed, use scoop command with installer argument to get the latest release of packer installed on Windows.

scoop install packer

How to Use Packer

Builders are used to generate images and create machines for various platforms from templates. You can see a full list of supported builders. A template is a configuration file used to define what image is built and its format is JSON.

Provisioners such as Ansible, Shell, Chef, PowerShell can be used while creating machine images with Packer. We will do more guides and share links on how to use Packer.

Also check:

How to Provision VMs on KVM with Terraform