When trying to publish docker images using `pants ...
# general
r
When trying to publish docker images using
pants publish
, I'm getting the following error message
Copy code
An image does not exist locally with the tag: <http://myregistry.azurecr.io/myrepository|myregistry.azurecr.io/myrepository>
The push refers to repository [<http://myregistry.azurecr.io/myrepository|myregistry.azurecr.io/myrepository>]
It seems like it's looking for a tag that is actually registry + repository?
1
c
that’s how it usually works, yes.
what tag(s) does it get when you package your image?
r
It's just the name of my branch, formatted to remove illegal characters.
c
it ought to have the registry address in the image name too when building it.. it doesn’t re-tag before publishing..
what’s your setup? (docker_image target and any docker options in pants.toml?)
r
Nothing in pants.toml other than a couple build args. I'm also setting the registry info in an environment variable like this:
Copy code
PANTS_DOCKER_REGISTRIES: |
    {
      "default": {
        "address": "${{ inputs.registry }}",
        "default": True,
        "skip_push": False,
        "extra_image_tags": ["${{ inputs.release_tag }}"]
      }
    }
I can probably move this into
pants.toml
if necessary though would prefer to keep it in an environment variable because we currently have 3 different registries we need to push different images to but that number is going down to 1 soon. So once I eliminate the other 2 registries from the build process I'll just configure the remaining one in pants.toml.
c
in env is fine 👍
so isn’t the registry part of the built image tag (name) ?
r
Here's my generated docker-info.json running locally using the tag test
Copy code
{
  "version": 1,
  "image_id": "sha256:df364f656454bb36d6b8e08c86426c5c3fe4556f93aa86ba1addafea0d26e2c2",
  "registries": [
    {
      "alias": "dagster",
      "address": "<http://myregistry.azurecr.io/my-repo-name|myregistry.azurecr.io/my-repo-name>",
      "repository": "my-project/my-subproject",
      "tags": [
        {
          "template": "test",
          "tag": "test",
          "uses_local_alias": false,
          "name": "<http://yregistry.azurecr.io/my-repo-name/my-project/my-subproject:test|yregistry.azurecr.io/my-repo-name/my-project/my-subproject:test>"
        }
      ]
    }
  ]
}
c
docker’s use of tag is confusing, as the tag images, but also a part of the tag is called a tag..
yes, so this is the image tag
<http://yregistry.azurecr.io/my-repo-name/my-project/my-subproject:test|yregistry.azurecr.io/my-repo-name/my-project/my-subproject:test>
which also should be the one it attempts to use during publish, is that not the case?
r
It's missing the
:test
c
huh?! ok, that would be interesting to nail down in a small repro case.
does
:test
come from your extra image tags?
r
yes
That was my intuition as well, will try it out
c
are you sure you have the same registry env config also during the publish call?
r
yeah I'm actually just running publish because it calls package for me
👍 1
and I have it declared top-level in the github workflow
c
that’s… really strange. I’ll take a closer look at this tonight. I think I have enough here to reproduce this, but if you’re able to get a small repro example that would be great (can use the example-docker as test bed)
if you don’t mind, can you share a redacted version of your
docker_image
target as well?
only the name/tag/repo stuff needed.. can ignore deps/instructions/sources
r
Yeah so I only have
repository
configured on the target, everything else comes from the env var
I'm trying it now using
image_tags
on the target instead of
extra_image_tags
👍 1
That just gave me a dependency inference issue
Okay when I run
docker image list
after
pants package
I'm not getting anything back
Not the case locally where I can see the image
Also seeing this on the Github runner:
Docker image ID: <unknown>
I see there are some recently closed tickets regarding docker buildx, which I am using, but I install it before calling
pants package
- maybe I need to install it before installing pants itself?
A HA
👀 1
c
maybe I need to install it before installing pants itself?
pants merely invokes
docker
cli, so I don’t think it matters what you have when installing pants.
r
The
setup-docker-buildx
github action uses
docker-container
driver by default
instead of just
docker
https://docs.docker.com/engine/reference/commandline/buildx_create/#docker-container-driver
Unlike
docker
driver, built images will not automatically appear in
docker images
and `build --load`needs to be used to achieve that.
c
oohh…
r
when I set the driver to docker it worked
c
sweet. that’s a nasty gotcha 😅