我知道在Dockerfile中,我可以使用以下方法扩展现有的docker映像:
FROM python/python
RUN pip install request但是如何在巴泽尔扩展它呢?
我不确定是否应该使用container_import,但是我得到了以下错误:
container_import(
name = "postgres",
base_image_registry = "some.artifactory.com",
base_image_repository = "/existing-image:v1.5.0",
layers = [
"//docker/new_layer",
],
)root@ba5cc0a3f0b7:/tcx# bazel build pkg:postgres-instance --verbose_failures --sandbox_debug
ERROR: /tcx/docker/postgres-operator/BUILD.bazel:12:17: in container_import rule //docker/postgres-operator:postgres:
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/2f47bbce04529f9da11bfed0fc51707c/external/io_bazel_rules_docker/container/import.bzl", line 98, column 35, in _container_import_impl
"config": ctx.files.config[0],
Error: index out of range (index is 0, but sequence has 0 elements)
ERROR: Analysis of target '//pkg:postgres-instance' failed; build aborted: Analysis of target '//docker/postgres-operator:postgres' failed
INFO: Elapsed time: 0.209s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 2 targets configured)发布于 2022-01-31 07:58:40
container_import是导入现有图像的正确规则。然而,它所做的只是进口,它没有从任何地方拉它。我认为您正在寻找container_pull,它将从存储库中提取图像,然后自动使用container_import将其转换为其他rules_docker规则。
若要添加新层,请使用container_image,将base设置为导入的映像,将tars设置为要添加的其他文件。或者,如果您想以其他格式添加内容,请参阅tars的交替文档(如debs或files)。
把所有的东西放在一起,就像这样在你的WORKSPACE里
container_pull(
name = "postgres",
registry = "some.artifactory.com",
repository = "existing-image",
tag = "v1.5.0",
)然后在一个BUILD文件中:
container_image(
name = "postgres_plus",
base = "@postgres//image",
tars = ["//docker/new_layer"],
)您遇到的具体问题是,container_pull.layers不是用于添加新层,而是用于指定要导入的映像的层。您可以以其他方式导入这些内容(http_archive、签入tar文件等),然后如果您正在做一些不寻常的事情,则可以手动指定它们,而不是使用container_pull。
https://stackoverflow.com/questions/70911361
复制相似问题