Docker build can not access mounted secrets file

Render says that we can use a secrets file and that is fine to use also when running the docker build.
How? I have a secrets created and when I try to source /etc/secrets/.env says the file doesn’t exist and for that reason my build fails as it doesn’t recnogize env vars needed for AWS specific.

Render lacks a lot of examples and good practical examples

1 Like

How can we access our generated secrets during docker building time?
This doesn’t help too much

You can store secret files (like .env or .npmrc files and private keys) in Render. These files can be accessed during builds and in your code just like regular files.
All secret files you create are available to read at the root of your repo (or Docker context). They are also available to load by absolute path at /etc/secrets/<filename>.

When I build tells me all the time /etc/secrets/my_file does not exist
I even added this to my docker file RUN --mount=type=secret,id=deployment,target=/var/www and nothing

How can I access a file that I generated during build time? Where is the file? It can never find it

1 Like

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.

Do you have a full example of this?

More details on secret files mounted in Docker builds can be found in our docs: Using Secrets with Docker | Render.