Docker build can not access mounted secrets file

Using secret files in Docker builds is supported, but you’ll have to make use of Dockerfile v1.2 syntax for secret mounts. How this is done is described at Build images with BuildKit | Docker Documentation. The secret ID will be your secret file name but with non-alphanumeric characters converted to _. For example, .env will be exposed as a secret with ID _env.

We’re working on documentation to make this clearer.