I created a an image to run a powershell script for vmware.
I need to provide to this script a password. After reading I arrive to this setup :
dockerfile
# Utiliser l'image de base PowerCLI
FROM vmware/powerclicore
RUN mkdir -p /home/pwsh
COPY script.ps1 /home/pwsh/
WORKDIR /home/pwsh
RUN --mount=type=secret,id=vcsa
CMD [ "/usr/bin/pwsh", "/home/pwsh/script.ps1"]
Something is missing… You already pass the secrets into your Dockerfile, and can already use it within the RUN instruction - but the thing is that you don’t do anything with it. The CMD is not(!) executed during image build, it is executed during container start.
FROM vmware/powerclicore
COPY script.ps1 /home/pwsh/
WORKDIR /home/pwsh
RUN --mount=type=secret,id=vcsa,target=/tmp/mysecret \
pwsh ./script.ps1
Like this, the script.ps1 could access the file /tmp/mysecret (which has the content of your secret) during build time.