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
- Create a new image tagged
my-app:latest
based on theubuntu:latest
image.
buildx imagetools create -t my-app:latest --from ubuntu:latest
- Build an image using a Dockerfile located in the
./my-app
directory, targeting thelinux/amd64
platform.
buildx imagetools create -f Dockerfile --context ./my-app --platform linux/amd64 -t my-app:latest
- 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
- Inspect the
my-app:latest
image.
buildx imagetools inspect my-app:latest
- Display the image layers for
my-app:latest
in a table format.
buildx imagetools inspect --layers --format table my-app:latest
- 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
- Push the
my-app:latest
image to themy-registry.com/my-namespace
registry.
buildx imagetools push my-app:latest my-registry.com/my-namespace/my-app:latest
- Push all tags associated with the
my-app
image to themy-registry.com
registry.
buildx imagetools push -a my-app my-registry.com
- Push the
my-app:latest
image to themy-registry.com
registry, targeting thelinux/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
- Pull the
my-app:latest
image from themy-registry.com/my-namespace
registry.
buildx imagetools pull my-registry.com/my-namespace/my-app:latest
- Pull all tags associated with the
my-app
image from themy-registry.com
registry.
buildx imagetools pull -a my-registry.com/my-namespace/my-app
- Pull the
my-app:latest
image from themy-registry.com
registry, targeting thelinux/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
- Tag the
my-app:latest
image asmy-app:v1.0
.
buildx imagetools tag my-app:latest my-app:v1.0
- Tag the
my-app:latest
image asmy-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
- Remove the
my-app:latest
image.
buildx imagetools rmi my-app:latest
- Force removal of the
my-app:latest
image.
buildx imagetools rmi -f my-app:latest
- 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
- Export the
my-app:latest
image to a tar archive namedmy-app.tar
.
buildx imagetools export -o my-app.tar my-app:latest
- Export the
my-app:latest
image to a compressed tar archive namedmy-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
- Import the
my-app.tar
image archive, tagging it asmy-app:latest
.
buildx imagetools import -t my-app:latest my-app.tar
- Force import of the
my-app.tar
image archive, tagging it asmy-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
- Save the
my-app:latest
image to a directory namedmy-app-saved
.
buildx imagetools save -o my-app-saved my-app:latest
- Save the
my-app:latest
image to a directory namedmy-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
- Load the Docker image from the
my-app-saved
directory, tagging it asmy-app:latest
.
buildx imagetools load -t my-app:latest my-app-saved
- Force load the Docker image from the
my-app-saved
directory, tagging it asmy-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
- Display the build history of the
my-app:latest
image.
buildx imagetools history my-app:latest
- 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
- Prune all dangling images.
buildx imagetools prune
- Force prune all dangling images.
buildx imagetools prune -f