Docker connot mount secrets

I encountered the exact same issue with Docker secrets file not accessed but I have not figured it out. I followed Using Secrets with Docker | Render, and this is my dockerfile:

FROM node:18.16.0

RUN apt-get update && apt-get install -y python3.11 python3-pip


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

RUN addgroup --system app && adduser --ingroup app --home /home/app --shell /bin/sh app

It just did not work, the environment variables were printed in the console during deployment but obviously, when the image was running it had no access to the secrets. Any help is appreciated.

Never mind, I don’t even need to mount secrets in dockerfile. This is for accessing secrets in build time which I don’t need to. The problem I was facing is actually that I could not access .env in run time even if I had configured it on render. I guess the problem was because .env was mounted to /app/.env instead of /app/src/.env? Anyway, I solved it by adding environment variables directly instead of copying the .env.

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