亚马逊 S3 缓存
目录
受限
这是一个实验性功能。界面和行为不稳定,未来版本可能会更改。
s3 缓存存储将生成的构建缓存上传到
亚马逊 S3 文件存储服务
或其它兼容 S3 的服务,例如
MinIO。
此缓存存储后端不支持默认的 docker 驱动程序。
要使用此功能,请使用不同的驱动程序创建一个新的构建器。有关更多信息,请参阅
构建驱动程序。
概述
$ docker buildx build --push -t <user>/<image> \
--cache-to type=s3,region=<region>,bucket=<bucket>,name=<cache-image>[,parameters...] \
--cache-from type=s3,region=<region>,bucket=<bucket>,name=<cache-image> .
以下表格描述了您可以传递给--cache-to和--cache-from的可用CSV参数。
| 名称 | 选项 | 类型 | 默认 | 描述 |
|---|---|---|---|---|
region | cache-to,cache-from | string | 必需。地理位置。 | |
bucket | cache-to,cache-from | string | 必需。S3 存储桶的名称。 | |
name | cache-to,cache-from | string | 缓存镜像的名称。 | |
endpoint_url | cache-to,cache-from | string | S3 存储桶的端点。 | |
blobs_prefix | cache-to,cache-from | string | 用于在 blob 文件名前添加的前缀。 | |
upload_parallelism | cache-to | 整数 | 4 | 并行上传的层数。 |
touch_refresh | cache-to | 时间 | 24h | 更新未更改的缓存层时间戳的间隔。 |
manifests_prefix | cache-to,cache-from | string | 用于在清单文件名前添加的前缀。 | |
use_path_style | cache-to,cache-from | 布尔值 | false | 当true时,在URL中使用bucket代替主机名。 |
access_key_id | cache-to,cache-from | string | See authentication. | |
secret_access_key | cache-to,cache-from | string | See authentication. | |
session_token | cache-to,cache-from | string | See authentication. | |
mode | cache-to | min,max | min | 导出的缓存层,请参阅 缓存模式。 |
ignore-error | cache-to | 布尔值 | false | 忽略由缓存导出失败引起的错误。 |
认证
Buildx 可以重用现有的 AWS 凭据,通过凭据文件或环境变量进行配置,用于将缓存推送到 S3 或从中拉取。
或者,您可以使用 access_key_id、secret_access_key 和
session_token 属性在命令行界面直接指定凭据。
请参阅 AWS Go SDK,指定凭据 以了解有关使用环境变量和凭据文件进行身份验证的详细信息。
进一步阅读
有关缓存的介绍,请参阅 Docker 构建缓存。
有关 s3 缓存后端的更多信息,请参阅
BuildKit README。