| 用途 | 加速依赖安装(apt/pip/npm/...) |
|---|---|
| 语法 | RUN --mount=type=cache,target=/root/.cache/pip ... |
| 依赖 | BuildKit(dockerfile 1.x) |
示例
示例
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
RUN --mount=type=cache,target=/root/.npm \
npm ci --prefer-offline缓存保存在构建器内部;CI 里配合 buildx 的 cache-to/cache-from 或复用同一构建器实例。