github.com/hashicorp/packer@v1.14.3/.release/docker/README.md (about) 1 # Packer Docker Container 2 3 The root of this repository contains the officially supported HashiCorp Dockerfile to build the hashicorp/packer docker image. The `dev` docker image should be built for local dev and testing, while the production docker image, `release`, is built in CI and makes use of CI-built binaries. The `light` and `full` docker images are built using the official binaries from releases.hashicorp.com. 4 5 ## License 6 7 This image is licensed under (BUSL-1.1)[https://github.com/hashicorp/packer/blob/main/LICENSE]. 8 9 ## Build 10 11 Refer to the Makefile of this repository, especially the `docker` and `docker-dev` targets to build a local version of the dev image based on the sources available. 12 13 ### Usage 14 15 This repository automatically builds containers for using the 16 [`packer`](https://developer.hashicorp.com/packer) command line program. It contains three distinct 17 varieties of build: a `light` version, which just contains the binary, 18 a `full` build, which contains the Packer binary with pre-installed plugins, 19 and a `dev` version, which compiles the binary from source 20 inside the container before exposing it for use. 21 22 ##### `light` 23 24 The `light` version of this container will copy the current stable version of 25 the binary, taken from releases.hashicorp.com, into the container. It will also 26 set it for use as the default entrypoint. This will be the best option for most uses, 27 especially if you are just looking to run the binary from a container. 28 The `latest` tag on DockerHub also points to this version. 29 30 You can use this version with the following: 31 ```shell 32 docker run <args> hashicorp/packer:light <command> 33 ``` 34 35 ##### `full` 36 37 The `full` version of the container builds upon `light` and pre-installs 38 the plugins officially maintained by HashiCorp. 39 40 You can use this version with the following: 41 ```shell 42 docker run <args> hashicorp/packer:full <command> 43 ``` 44 45 You can view the list of pre-installed plugins with the following: 46 ```shell 47 docker run <args> hashicorp/packer:full plugins installed 48 ``` 49 50 ##### `dev` 51 52 The `dev` version of this container contains all of the source code found in 53 the current ref of this [repository](https://github.com/hashicorp/packer). Using [Google's 54 official `golang` image](https://hub.docker.com/_/golang/) as a base, this 55 container will copy the source from the current branch, build the binary, and 56 expose it for running. Because all build artifacts are included, it should be quite a bit larger than 57 the `light` image. This version of the container is most useful for development or 58 debugging. 59 60 You can use this version with the following: 61 ```shell 62 docker run <args> hashicorp/packer:dev <command> 63 ``` 64 65 #### Running a build: 66 67 The easiest way to run a command that references a configuration with one or more template files, is to mount a volume for the local workspace. 68 69 Running `packer init` 70 ```shell 71 docker run \ 72 -v `pwd`:/workspace -w /workspace \ 73 -e PACKER_PLUGIN_PATH=/workspace/.packer.d/plugins \ 74 hashicorp/packer:latest \ 75 init . 76 ``` 77 78 ~> **Note**: packer init is available from Packer v1.7.0 and later 79 80 The command will mount the working directory (`pwd`) to `workspace`, which is the working directory (`-w`) inside the container. 81 Any plugin installed with `packer init` will be installed under the directory specified under the `PACKER_PLUGIN_PATH` environment variable. `PACKER_PLUGIN_PATH` must be set to a path inside the volume mount so that plugins can become available at `packer build`. 82 83 Running `packer build` 84 ```shell 85 docker run \ 86 -v `pwd`:/workspace -w /workspace \ 87 -e PACKER_PLUGIN_PATH=/workspace/.packer.d/plugins \ 88 hashicorp/packer:latest \ 89 build . 90 ``` 91 ##### Building old-legacy JSON templates 92 93 For old-legacy JSON, the build command must specify the template file(s). 94 95 ```shell 96 docker run \ 97 -v `pwd`:/workspace -w /workspace \ 98 hashicorp/packer:latest \ 99 build template.json 100 ``` 101 102 For the [manual installation](https://www.packer.io/docs/plugins#installing-plugins) of third-party plugins, we recommended that plugin binaries are placed under a sub-directory under the working directory. Add `-e PACKER_PLUGIN_PATH=/workspace/<subdirectory_plugin_path>` to the command above to tell Packer where the plugins are. 103 104 To pass a var file (`var.json`) to the build command: 105 106 ```shell 107 docker run \ 108 -v `pwd`:/workspace -w /workspace \ 109 hashicorp/packer:latest \ 110 build --var-file var.json template.json 111 ``` 112 `var.json` is expected to be inside the local working directory (`pwd`) and in the container's workspace mount.