• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Packer
  • Install
  • Tutorials
  • Documentation
  • Guides
  • Plugins
  • Try Cloud(opens in new tab)
  • Sign up
Docker

Skip to main content
6 tutorials
  • Install Packer
  • Build an Image
  • Provision
  • Variables
  • Parallel Builds
  • Post-Processors

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Packer
  3. Tutorials
  4. Docker
  5. Install Packer

Install Packer

  • 5min

  • PackerPacker

Packer may be installed in the following ways:

  • Using a precompiled binary. We release binaries for all supported platforms and architectures. This method is recommended for most users.
  • Installing from source. This method is only recommended for advanced users.
  • Using your system's package manager.

Installing Packer

Retrieve the packer binary by downloading a pre-compiled binary or compiling it from source.

To install the precompiled binary, download the appropriate package for your system. Packer is currently packaged as a zip file.

After downloading Packer, unzip the package. Packer runs as a single binary named packer.

Finally, make sure that the packer binary is available on your PATH. This process will differ depending on your operating system.

Print a colon-separated list of locations in your PATH.

$ echo $PATH

Move the Packer binary to one of the listed locations. This command assumes that the binary is currently in your downloads folder and that your PATH includes /usr/local/bin, but you can customize it if your locations are different.

$ mv ~/Downloads/packer /usr/local/bin/

For more detail about adding binaries to your path, see this Stack Overflow article.

This Stack Overflow article contains instructions for setting the PATH on Windows through the user interface.

To compile from source, you will need Go installed and configured properly as well as a copy of git in your PATH.

Create a directory in your GOPATH for the code.

$ mkdir -p $(go env GOPATH)/src/github.com/hashicorp && cd $_

Clone the Packer repository from GitHub into your GOPATH.

$ git clone https://github.com/hashicorp/packer.git

Change into the packer directory.

$ cd packer

Build Packer for your current system and put the binary in ./bin/ (relative to the git checkout). The make dev target is just a shortcut that builds packer for only your local build environment (no cross-compiled targets).

$ make dev

Homebrew is a free and open-source package management system for Mac OS X. Install the official Packer formula from the terminal.

First, install the HashiCorp tap, a repository of all our Homebrew packages.

$ brew tap hashicorp/tap

Now, install Packer with hashicorp/tap/packer.

$ brew install hashicorp/tap/packer

NOTE: This installs a signed binary and is automatically updated with every new official release.

To update to the latest, run

$ brew upgrade hashicorp/tap/packer

Chocolatey is a free and open-source package management system for Windows.

If you're using Windows and Chocolatey, you can install Packer by running choco install.

$ choco install packer

NOTE: The Chocolatey package is not currently maintained by HashiCorp.

HashiCorp officially maintains and signs packages for the following Linux distributions.

Add the HashiCorp GPG key.

$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

Add the official HashiCorp Linux repository.

$ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

Update and install.

$ sudo apt-get update && sudo apt-get install packer

Install yum-config-manager to manage your repositories.

$ sudo yum install -y yum-utils

Use yum-config-manager to add the official HashiCorp Linux repository.

$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Install.

$ sudo yum -y install packer

Install dnf config-manager to manage your repositories.

$ sudo dnf install -y dnf-plugins-core

Use dnf config-manager to add the official HashiCorp Linux repository.

$ sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo

Install.

$ sudo dnf -y install packer

Install yum-config-manager to manage your repositories.

$ sudo yum install -y yum-utils

Use yum-config-manager to add the official HashiCorp Linux repository.

$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

Install.

$ sudo yum -y install packer

TIP: Now that you have added the HashiCorp repository, you can install Terraform, Vault, Consul, and Nomad with the same command.

Verifying the Installation

After installing Packer, verify the installation worked by opening a new command prompt or console, and checking that packer is available:

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

Available commands are:
    build           build image(s) from template
    console         creates a console for testing variable interpolation
    fix             fixes templates from old versions of packer
    fmt             Rewrites HCL2 config files to canonical format
    hcl2_upgrade    transform a JSON template into an HCL2 configuration
    init            Install missing plugins or upgrade plugins
    inspect         see components of a template
    validate        check that a template is valid
    version         Prints the Packer version

If you get an error that packer could not be found, then your PATH environment variable was not set up properly. Please go back and ensure that your PATH variable contains the directory which has Packer installed.

Otherwise, Packer is installed and you're ready to go!

Troubleshooting

On some distributions, there may be another tool named packer installed by default. The following error indicates that there is a name conflict.

$ packer
/usr/share/cracklib/pw_dict.pwd: Permission denied
/usr/share/cracklib/pw_dict: Permission denied

Note: On Arch Linux, there is a package named packer in the main repository and in the AUR. The package packer in the AUR is an old name for a package management tool for Arch, it's not HashiCorp Packer.

To fix this, create a symlink to packer that uses a different name like packer.io, or invoke the packer binary you want using its absolute path, e.g. /usr/local/packer.

 Back to Collection
 Next

This tutorial also appears in:

  •  
    6 tutorials
    Getting Started with AWS
    HashiCorp Packer automates the creation of any type of machine image, including AWS AMIs. You'll build an Ubuntu machine image on AWS in this tutorial.
    • Packer

On this page

  1. Install Packer
  2. Installing Packer
  3. Verifying the Installation
  4. Troubleshooting
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)