buildx imagetools

The buildx imagetools command is a powerful tool for working with Docker images. It offers a comprehensive set of functionalities for managing, inspecting, and manipulating Docker images. This outline provides an in-depth overview of the available commands, options, and examples for leveraging buildx imagetools.

buildx imagetools create

The buildx imagetools create command enables the creation of new Docker images based on various sources.

Usage

buildx imagetools create [OPTIONS] SOURCE...
          

Options:

  • -t, --tag=TAG (string): Sets a tag for the created image.
  • -f, --from=FROM (string): Specifies the source image to use for building the new image.
  • --context=CONTEXT (string): Sets the context directory for the image build.
  • --platform=PLATFORM (string): Sets the target platform for the image build.
  • --no-cache (bool): Disables caching during the build process.
  • --compress (bool): Compresses the image layers.
  • --force (bool): Forces image creation even if it already exists.
  • --push (bool): Pushes the created image to a registry.
  • --output=OUTPUT (string): Sets the output format for the created image (e.g., docker, oci).
  • --label=LABEL (string): Adds a label to the image.

Examples

  1. Create a new image tagged my-app:latest based on the ubuntu:latest image.
buildx imagetools create -t my-app:latest --from ubuntu:latest
          
  1. Build an image using a Dockerfile located in the ./my-app directory, targeting the linux/amd64 platform.
buildx imagetools create -f Dockerfile --context ./my-app --platform linux/amd64 -t my-app:latest
          
  1. Create an image from a tarball located at my-image.tar, compressing the layers.
buildx imagetools create --from my-image.tar --compress -t my-image:latest
          

buildx imagetools inspect

The buildx imagetools inspect command allows you to retrieve detailed information about Docker images.

Usage

buildx imagetools inspect [OPTIONS] IMAGE...
          

Options:

  • -a, --all (bool): Displays all image details.
  • -s, --short (bool): Displays only the image ID and tag.
  • -f, --format=FORMAT (string): Sets the output format (e.g., json, table).
  • --history (bool): Shows the build history of the image.
  • --layers (bool): Lists the image layers.
  • --labels (bool): Displays the image labels.
  • --size (bool): Shows the image size.

Examples

  1. Inspect the my-app:latest image.
buildx imagetools inspect my-app:latest
          
  1. Display the image layers for my-app:latest in a table format.
buildx imagetools inspect --layers --format table my-app:latest
          
  1. Get the history of the my-app:latest image.
buildx imagetools inspect --history my-app:latest
          

buildx imagetools push

The buildx imagetools push command pushes an existing Docker image to a registry.

Usage

buildx imagetools push [OPTIONS] IMAGE...
          

Options:

  • -a, --all (bool): Pushes all tags associated with the image.
  • -t, --tag=TAG (string): Specifies a tag for the image.
  • --platform=PLATFORM (string): Sets the target platform for the push operation.
  • --no-cache (bool): Disables caching during the push process.
  • --compress (bool): Compresses the image layers.
  • --force (bool): Forces image push even if it already exists in the registry.

Examples

  1. Push the my-app:latest image to the my-registry.com/my-namespace registry.
buildx imagetools push my-app:latest my-registry.com/my-namespace/my-app:latest
          
  1. Push all tags associated with the my-app image to the my-registry.com registry.
buildx imagetools push -a my-app my-registry.com
          
  1. Push the my-app:latest image to the my-registry.com registry, targeting the linux/arm64 platform.
buildx imagetools push --platform linux/arm64 my-app:latest my-registry.com
          

buildx imagetools pull

The buildx imagetools pull command retrieves a Docker image from a registry.

Usage

buildx imagetools pull [OPTIONS] IMAGE...
          

Options:

  • -a, --all (bool): Pulls all tags associated with the image.
  • -t, --tag=TAG (string): Specifies a tag for the image.
  • --platform=PLATFORM (string): Sets the target platform for the pull operation.
  • --no-cache (bool): Disables caching during the pull process.
  • --compress (bool): Compresses the image layers.
  • --force (bool): Forces image pull even if it already exists locally.

Examples

  1. Pull the my-app:latest image from the my-registry.com/my-namespace registry.
buildx imagetools pull my-registry.com/my-namespace/my-app:latest
          
  1. Pull all tags associated with the my-app image from the my-registry.com registry.
buildx imagetools pull -a my-registry.com/my-namespace/my-app
          
  1. Pull the my-app:latest image from the my-registry.com registry, targeting the linux/arm64 platform.
buildx imagetools pull --platform linux/arm64 my-registry.com/my-namespace/my-app:latest
          

buildx imagetools tag

The buildx imagetools tag command adds a new tag to an existing Docker image.

Usage

buildx imagetools tag [OPTIONS] IMAGE...
          

Options:

  • -f, --force (bool): Forces tag creation even if it already exists.

Examples

  1. Tag the my-app:latest image as my-app:v1.0.
buildx imagetools tag my-app:latest my-app:v1.0
          
  1. Tag the my-app:latest image as my-registry.com/my-namespace/my-app:v1.0.
buildx imagetools tag my-app:latest my-registry.com/my-namespace/my-app:v1.0
          

buildx imagetools rmi

The buildx imagetools rmi command removes Docker images.

Usage

buildx imagetools rmi [OPTIONS] IMAGE...
          

Options:

  • -f, --force (bool): Forces image removal without confirmation.
  • -P, --prune (bool): Removes all dangling images (images without tags) along with the specified images.

Examples

  1. Remove the my-app:latest image.
buildx imagetools rmi my-app:latest
          
  1. Force removal of the my-app:latest image.
buildx imagetools rmi -f my-app:latest
          
  1. Remove the my-app:latest image and all dangling images.
buildx imagetools rmi -P my-app:latest
          

buildx imagetools export

The buildx imagetools export command exports a Docker image to a tar archive.

Usage

buildx imagetools export [OPTIONS] IMAGE...
          

Options:

  • -o, --output=OUTPUT (string): Sets the output file for the exported image.
  • --compress (bool): Compresses the image layers.

Examples

  1. Export the my-app:latest image to a tar archive named my-app.tar.
buildx imagetools export -o my-app.tar my-app:latest
          
  1. Export the my-app:latest image to a compressed tar archive named my-app.tar.gz.
buildx imagetools export -o my-app.tar.gz --compress my-app:latest
          

buildx imagetools import

The buildx imagetools import command imports a Docker image from a tar archive.

Usage

buildx imagetools import [OPTIONS] FILE...
          

Options:

  • -t, --tag=TAG (string): Sets a tag for the imported image.
  • -f, --force (bool): Forces image import even if it already exists.

Examples

  1. Import the my-app.tar image archive, tagging it as my-app:latest.
buildx imagetools import -t my-app:latest my-app.tar
          
  1. Force import of the my-app.tar image archive, tagging it as my-app:latest.
buildx imagetools import -t my-app:latest -f my-app.tar
          

buildx imagetools save

The buildx imagetools save command saves a Docker image to a directory.

Usage

buildx imagetools save [OPTIONS] IMAGE...
          

Options:

  • -o, --output=OUTPUT (string): Sets the output directory for the saved image.
  • --compress (bool): Compresses the image layers.

Examples

  1. Save the my-app:latest image to a directory named my-app-saved.
buildx imagetools save -o my-app-saved my-app:latest
          
  1. Save the my-app:latest image to a directory named my-app-saved, compressing the image layers.
buildx imagetools save -o my-app-saved --compress my-app:latest
          

buildx imagetools load

The buildx imagetools load command loads a Docker image from a directory.

Usage

buildx imagetools load [OPTIONS] FILE...
          

Options:

  • -t, --tag=TAG (string): Sets a tag for the loaded image.
  • -f, --force (bool): Forces image load even if it already exists.

Examples

  1. Load the Docker image from the my-app-saved directory, tagging it as my-app:latest.
buildx imagetools load -t my-app:latest my-app-saved
          
  1. Force load the Docker image from the my-app-saved directory, tagging it as my-app:latest.
buildx imagetools load -t my-app:latest -f my-app-saved
          

buildx imagetools history

The buildx imagetools history command lists the build history of a Docker image.

Usage

buildx imagetools history [OPTIONS] IMAGE...
          

Options:

  • -a, --all (bool): Displays all build stages.
  • -f, --format=FORMAT (string): Sets the output format (e.g., json, table).
  • --no-trunc (bool): Disables truncation of output.

Examples

  1. Display the build history of the my-app:latest image.
buildx imagetools history my-app:latest
          
  1. Show the build history of the my-app:latest image in a table format.
buildx imagetools history --format table my-app:latest
          

buildx imagetools prune

The buildx imagetools prune command removes all dangling images (images without tags).

Usage

buildx imagetools prune [OPTIONS]
          

Options:

  • -f, --force (bool): Forces image removal without confirmation.

Examples

  1. Prune all dangling images.
buildx imagetools prune
          
  1. Force prune all dangling images.
buildx imagetools prune -f