Docker secrets file not accessed

My service’s Docker build fails because it’s unable to get the environment variables from the secrets file.

I followed the instructions here: Docker secrets

How do I get Render to read the secrets file, without changing my app to read from that path /etc/secrets/.env just so that it works for Render?

My local build works. I specify the env file “.env” during the build:

docker build --secret id=_env,src=.env -t...


# syntax = docker/dockerfile:1.2
FROM python:3.10


RUN --mount=type=secret,id=_env,dst=/etc/secrets/.env cat /etc/secrets/.env

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install --no-cache-dir -r requirements.txt
COPY . /app

CMD ["uvicorn", "main:app", "--host", "", "--port", "80"]    


I think we spoke on a ticket and you were able to resolve this particular issue. I think you resolved it by changing the cat to cp in the secrets RUN command?


Yes I resolved it. Maybe the relevant Render doc could be updated please? To clarify that the secret file is only accessible in the same RUN command where it is mounted.

Thanks Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.