Amazon S3 缓存
目录
受限
这是一个实验性功能。接口和行为不稳定,可能在未来的版本中发生变化。
s3 缓存存储将您的构建缓存上传到
Amazon 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参数。
| Name | Option | Type | Default | Description |
|---|---|---|---|---|
region | cache-to,cache-from | String | Required. Geographic location. | |
bucket | cache-to,cache-from | String | Required. Name of the S3 bucket. | |
name | cache-to,cache-from | String | Name of the cache image. | |
endpoint_url | cache-to,cache-from | String | Endpoint of the S3 bucket. | |
blobs_prefix | cache-to,cache-from | String | Prefix to prepend to blob filenames. | |
upload_parallelism | cache-to | Integer | 4 | Number of parallel layer uploads. |
touch_refresh | cache-to | Time | 24h | Interval for updating the timestamp of unchanged cache layers. |
manifests_prefix | cache-to,cache-from | String | Prefix to prepend on manifest filenames. | |
use_path_style | cache-to,cache-from | Boolean | false | When true, uses bucket in the URL instead of hostname. |
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 | Cache layers to export, see cache mode. |
ignore-error | cache-to | Boolean | false | Ignore errors caused by failed cache exports. |
认证
Buildx 可以重用现有的 AWS 凭据,这些凭据可以通过凭据文件或环境变量进行配置,用于将缓存推送到 S3 或从 S3 拉取缓存。或者,您可以使用 access_key_id、secret_access_key 和 session_token 属性直接在 CLI 上指定凭据。
请参考 AWS Go SDK, 指定凭证 了解关于使用环境变量和凭证文件进行身份验证的详细信息。
进一步阅读
有关缓存的介绍,请参见 Docker 构建缓存。
有关s3缓存后端的更多信息,请参阅
BuildKit README。