我想使用 Bazel 精简 debian 10 Docker 映像,然后将结果展平为单层映像。
这是我的代码:
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_flatten", "container_bundle", "container_import")
load("@io_bazel_rules_docker//docker/util:run.bzl", "container_run_and_commit")
container_run_and_commit(
name = "debian10_slimmed_layers",
commands = ["rm -rf /usr/share/man/*"],
image = "@debian10//image",
)
# Create an image just so we can flatten it.
container_image(
name = "debian10_slimmed_image",
base = ":debian10_slimmed_layers",
)
# Flatten the layers to a single layer.
container_flatten(
name = "debian10_flatten",
image = ":debian10_slimmed_image",
)
我陷入困境的地方是我无法弄清楚如何使用 的输出debian10_flatten
来生成可运行的 Docker 映像。
我试过:
container_image(
name = "debian10",
base = ":debian10_flatten",
)
那失败了:
2021/06/27 13:16:25 Unable to load docker image from bazel-out/k8-fastbuild/bin/debian10_flatten.tar:
file manifest.json not found in tar