microscopic-parrot-94355
01/25/2025, 5:20 PMdocker_environment
with a locally-built image?
Slightly longer version: It seems that a docker_environment requires a manifest ID which does not exist unless and until an image is pushed to a V2 registry. There seems to be a bug (I'll add details in a ๐งต) where pants will treat the image ID as a manifest ID and attempt to pull a non-existent image from a potentially nonexistent registry even though the image exists locally. Can this be fixed?
Even longer version: See thread; relevant code is here.microscopic-parrot-94355
01/25/2025, 5:20 PMdocker_image(
name = "cross-compiler",
dependencies = [":cargo-lock"],
source = "Dockerfile",
skip_push = True,
repository = "example/rust-cross-compiler",
)
docker_environment(
name = "cross-compiler-env",
image = "example/rust-cross-compiler",
)
I can create the image locally:
pants package examples/docker-cross-compile:cross-compiler
09:15:49.74 [INFO] Completed: Building docker image example/rust-cross-compiler:latest
09:15:49.74 [INFO] Wrote dist/examples.docker-cross-compile/cross-compiler.docker-info.json
Built docker image: example/rust-cross-compiler:latest
Docker image ID: sha256:f180e7508550165ca5aef038aa07b32057a2463cdd3f81224a211d5145049915
But if I try to package the other targets, I hit the ๐ mentioned above:
pants package examples/docker-cross-compile/::
09:17:12.61 [INFO] Completed: Building docker image example/rust-cross-compiler:latest
09:17:13.31 [INFO] Completed: Pulling Docker image `sha256:f180e7508550165ca5aef038aa07b32057a2463cdd3f81224a211d5145049915` because the image is missing locally.
09:17:13.32 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
IntrinsicError: Failed to pull Docker image `sha256:f180e7508550165ca5aef038aa07b32057a2463cdd3f81224a211d5145049915`: DockerResponseServerError { status_code: 404, message: "pull access denied for sha256, repository does not exist or may require 'docker login': denied: requested access to the resource is denied" }
Note the error: The image is being referenced by the image ID (which does exist locally) but it's being treated as a manifest ID (which does not exist at all):
docker image list --digests example/rust-cross-compiler
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
example/rust-cross-compiler latest <none> f180e7508550 24 hours ago 1.78GB
microscopic-parrot-94355
01/25/2025, 5:25 PMdocker_image(
name = "cross-compiler",
dependencies = [":cargo-lock"],
source = "Dockerfile",
# skip_push = True, # Allow push
repository = "mccoym2/rust-cross-compiler",
)
docker_environment(
name = "cross-compiler-env",
image = "mccoym2/rust-cross-compiler",
)
Second, I publish the image:
pants publish examples/docker-cross-compile:cross-compiler
09:21:36.66 [INFO] Completed: Building docker image mccoym2/rust-cross-compiler:latest
09:21:36.66 [INFO] Packaged examples.docker-cross-compile/cross-compiler.docker-info.json
The push refers to repository [<http://docker.io/mccoym2/rust-cross-compiler|docker.io/mccoym2/rust-cross-compiler>]
873cf0224b25: Layer already exists
586888d725c7: Layer already exists
5f70bf18a086: Layer already exists
500d46b9d1bd: Layer already exists
c9c6219cc174: Layer already exists
bc63b413552d: Layer already exists
9cfa8c60a416: Layer already exists
8087b953cf2e: Layer already exists
d9fbef8fc08c: Layer already exists
86d145e933bc: Layer already exists
latest: digest: sha256:631947d62cb850da3ea590bc53b91dfd4b53711eb104f3af3f83da4af04fde8b size: 2420
Note that the MANIFEST ID now appears at the final step. I can now add this to the BUILD file:
docker_environment(
name = "cross-compiler-env",
image = "mccoym2/rust-cross-compiler@sha256:631947d62cb850da3ea590bc53b91dfd4b53711eb104f3af3f83da4af04fde8b",
)
Now I'm able to package everything:
pants package examples/docker-cross-compile/::
09:24:24.10 [INFO] Completed: Building docker image mccoym2/rust-cross-compiler:latest
09:25:14.63 [INFO] Wrote dist/examples.docker-cross-compile/cross-compiler.docker-info.json
Built docker image: mccoym2/rust-cross-compiler:latest
Docker image ID: sha256:f180e7508550165ca5aef038aa07b32057a2463cdd3f81224a211d5145049915
09:25:14.63 [INFO] Wrote dist/examples.docker-cross-compile/hello-cross
microscopic-parrot-94355
01/25/2025, 5:29 PMrefined-addition-53644
01/26/2025, 5:44 PMmicroscopic-parrot-94355
01/27/2025, 2:53 AM