8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
-
I'm trying to access .env variables as part of my Docker build process in the Dockerfile, e.g.
.env
Dockerfile
in .env I have
AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=...
As per the documentation, I then expose them to the builder like so in deploy.yml:
deploy.yml
builder: cache: type: registry secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY
but when I try to access them in the Dockerfile:
ARG AWS_ACCESS_KEY_ID ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} ARG AWS_SECRET_ACCESS_KEY ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} RUN aws s3 sync ....
They aren't accessible (in my case aws s3 sync breaks with fatal error: Unable to locate credentials).
aws s3 sync
fatal error: Unable to locate credentials
Anybody can point out how to access .env vars in Dockerfile?
Beta Was this translation helpful? Give feedback.
My bad, I'm new to Docker secrets, got it all working:
RUN --mount=type=secret,id=AWS_ACCESS_KEY_ID \ --mount=type=secret,id=AWS_SECRET_ACCESS_KEY \ AWS_ACCESS_KEY_ID=$(cat /run/secrets/AWS_ACCESS_KEY_ID) \ AWS_SECRET_ACCESS_KEY=$(cat /run/secrets/AWS_SECRET_ACCESS_KEY) \ aws s3 sync ....
lost some time as i also missed the mount part of the documentation. maybe it could be highlighted in the docs ;)