Skip to main content
In this guide, you’ll learn how to utilize the Pack CLI for building container images from your source code. Before proceeding, ensure that all prerequisites are met.
Docker must be installed on your machine, as Pack CLI relies on Docker to create and pull images.
The image shows a diagram indicating that Docker needs to be installed on a machine, labeled as a prerequisite.

Installing the Pack CLI

The installation process for the Pack CLI varies by operating system and distribution. For Ubuntu users, follow these steps to add the repository, update your package list, and install the CLI:
After adding the repository, update your packages and install the Pack CLI to get full access to its features.

Suggesting Builders

One of the first commands to explore is pack builder suggest. This command lists recommended builders that you can use to create images from your source code. These builders have been rigorously tested and are widely used in the community. To see the suggested builders, execute:
The output may resemble the following:
This list includes multiple builders such as the Google builder (gcr.io/buildpacks/builder:google-22), which is based on Ubuntu 22.04 and supports a wide range of languages, as well as several options from Heroku and Paketo Buildpacks. If you have not created your own builder, simply choose one of these recommended options.

Building an Image

Once you’ve selected a builder, you can build an image using the pack build command. Specify the image name and select a builder with the --builder flag. To publish the image directly to Docker Hub or another container registry, include the --publish flag. For example:
In this command, the image is named “my-image” and is built using the cnbs/sample-builder:jammy builder. You can modify the builder image and image name as needed.

Inspecting the Built Image

After building your image, you can inspect it to obtain detailed information such as the base image, layers, run image, buildpacks used, and the processes configured for your application. Run the following command:
A typical sample output might look like this:
This detailed output provides valuable insights into your image, including stack information, layered components, and runtime configurations. By following these steps, you can efficiently install, configure, build, and inspect container images using the Pack CLI. For more detailed information on buildpacks, check out the official documentation.

Watch Video