Dockerfile instructions
RUN secret mount
Temporary secret input for a build operation. The default file path is /run/secrets/<id>. Avoid printing or copying it. Secret contents do not automatically invalidate cache. Required input is checked on execution, not proven by a cached result.
Formal Syntax & Structure
docker syntaxdocker
RUN --mount=type=secret,id=<id>[,required=true] <command>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| id | string | Identifier shared with CLI secret input. |
| required | string | Require the input when the operation executes. |
Working Example
Example Snippetdocker
FROM busybox:1.37RUN --mount=type=secret,id=demo,required=true test -s /run/secrets/demoRUN printf "checked\n" > /result.txtCMD ["cat", "/result.txt"]