Skip to content

CICD-121 · Use a mount-based build secret ​

Encyclopedia · Docker image building · All snippets

Previous · CICD-120 · Next · CICD-122

1. Where it fits ​

  • Placement In the Dockerfile used by the trusted BuildKit job.
  • Prerequisites Docker Engine or BuildKit on a trusted lab runner.
  • Platforms local-lab.

2. Copy the snippet ​

dockerfile
# syntax=docker/dockerfile:1
FROM python:3.12-slim
RUN --mount=type=secret,id=pip_config,target=/etc/pip.conf python -m pip install --no-cache-dir approved-internal-tool==1.2.3

3. How it works ​

Build instructions are processed in order. ARG applies before FROM only when declared at that scope.

4. Verify the result ​

Supply --secret id=pip_config,src=PATH through a trusted build. Avoid echoing secret contents.

Watch for. Use the intended trusted execution context. Keep secret values out of traces, artifacts and debug output.

Validation untested. Status definitions.