Rules_docker: Container push no longer prints sha256 digest

Created on 14 Oct 2019  路  3Comments  路  Source: bazelbuild/rules_docker

Hi,

we're unable to retrieve the sha256 digest when we run container push for an image. We use the digest when we create a job manifest for deployment, as part of a bazel run command for a deploy script.

See comment https://github.com/bazelbuild/rules_docker/issues/371#issuecomment-378023577 which describes how it used to work. Our deploy script was broken after upgrade to bazel 1.0 and rules_docker 0.12.0.

Our workaround is to use a stamp, but this means we get a new release for each build rather than only when the digest changes.

Any way of printing the sha256 digest to stdout in the pusher script?

Most helpful comment

Hi @gorset,

Sorry for breaking your use case. Note that the stdout of our binaries isn't part of their API and therefore I would recommend against depending on them.

For your use case, the container_push rule generates an output digest file with the sha256 digest of the image it will push when run with bazel run. So if you have a container_push target:

container_push(
  name = "push_image",
 ...
)

If you do bazel build //path/to:push_image.digest, it will produce a file with the sha256 digest of the image. I suggest depending on this file in downstream rules or print its contents using

bazel build //path/to:push_image.digest
cat bazel-bin/path/to/push_image.digest

All 3 comments

Hi @gorset,

Sorry for breaking your use case. Note that the stdout of our binaries isn't part of their API and therefore I would recommend against depending on them.

For your use case, the container_push rule generates an output digest file with the sha256 digest of the image it will push when run with bazel run. So if you have a container_push target:

container_push(
  name = "push_image",
 ...
)

If you do bazel build //path/to:push_image.digest, it will produce a file with the sha256 digest of the image. I suggest depending on this file in downstream rules or print its contents using

bazel build //path/to:push_image.digest
cat bazel-bin/path/to/push_image.digest

That works. Thanks!

Rather than hard-code the output path or write complicated starlark just to get the digest, one can do this:
IMAGE_SHA256=$(bazel run --run_under "cat" //my/pkg1:push1.digest)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msiebuhr picture msiebuhr  路  8Comments

henrywong-seekers picture henrywong-seekers  路  7Comments

nictuku picture nictuku  路  3Comments

GauntletWizard picture GauntletWizard  路  9Comments

mouadino picture mouadino  路  10Comments