Right way to use secret flag in docker buildkit

  docker, docker-buildkit

I am struggling with the same problem mentioned by Gavin on
this question.

Specifically in with new
docker build secret information

What is the right way to use it that feature?

Looking around on the internet I only found some variations of the same example in docker documentation mentioned above, which prints the secret on build time. Maybe I didn’t fully understand the example, so please help me.

If there is no way to get the secret in build time an use in another part of a Dockerfile (e.g. an ARG variable or RUN command), when and how that new feature can be used to truly keep my secret safe and also do the work?

My go is to use this new feature in build time and also keep my secret information safe in case someone get my image file and execute a history on it.

Thanks in advance

Source: Docker Questions