312-97 practice question 18 of 35

(Robin Tunney has been working as a DevSecOps engineer in an IT company located in Charleston, South Carolin a. She would like to build a customized…

Full set: 100 questions
(Robin Tunney has been working as a DevSecOps engineer in an IT company located in Charleston, South Carolin a. She would like to build a customized docker image using HashiCorp Packer. Therefore, she installed Packer and created a file docker-ubuntu.pkr.hcl; she then added HCL block to it and saved the file. Which of the following commands should Robin execute to build the Docker image using Packer?)
Answer options
A: packer build docker-ubuntu.pkr.hcl. Correct answer
B: packer -b docker-ubuntu.pkr.hcl.
C: packer b docker-ubuntu.pkr.hcl.
D: packer -build docker-ubuntu.pkr.hcl.
Correct Answer:
A. packer build docker-ubuntu.pkr.hcl.
Explanation

HashiCorp Packer is a tool for creating identical machine images for multiple platforms from a single source configuration. The primary command to initiate the image creation process is build. The correct syntax for this command is packer build , where is the path to the Packer configuration file (e.g., a .pkr.hcl or .json file). This command instructs Packer to parse the template, validate its configuration, and then execute the defined builders and provisioners to create the specified artifact, such as a Docker image.

Why Incorrect

B. The -b flag is not a valid shorthand or option for the build subcommand in the Packer CLI.
C. The single letter b is not a recognized alias for the build subcommand in Packer.
D. The build subcommand should not be prefixed with a hyphen; hyphens are reserved for flags and options, not primary commands.

References

1. HashiCorp Packer Official Documentation, "Commands: build." The documentation clearly states the command usage is packer build [options] . It describes this as the command that "kicks off a build for the given template." (Source: developer.hashicorp.com/packer/docs/commands/build).

2. HashiCorp Packer Official Documentation, "Get Started - Build an image." The tutorial guides users to run the build process using the command packer build ., which demonstrates the build subcommand followed by the template location. (Source: developer.hashicorp.com/packer/tutorials/docker-get-started/docker-get-started-build-image, "Build the image" section).

Scroll to Top