A build argument is a value passed to a container image build, for example with a Docker build command, to customize how the image is built. It is commonly used for version numbers and settings that apply only at build time.

It matters for security because values passed this way can remain visible in the finished image. Depending on how the build is written, they can be recovered from the image's metadata or history by anyone who can pull the image, so passing a secret as a build argument can leak it.

Not every build argument ends up exposed, and what is stored depends on the tooling and how the file is written, so the risk should be checked and not assumed. Some build systems offer a safer way to give a build access to a secret temporarily without storing it in the image.

To avoid problems, do not pass credentials as build arguments, use the build system's dedicated secret mechanism where it exists, inspect the finished image for exposed values and rotate any credential that has been baked into an image.