#publish to registry running locally

1 messages ยท Page 1 of 1 (latest)

cloud flint
#

I 'm trying to automate my local development environment. I have a dag that is building a container and I want to publish this to a registry that I am running locally using docker, so that I can deploy to kubernetes running locally using kind. The registry is running with port 5000 exposed, but am getting the following error message when trying to publish using the go sdk

panic: input:1: container.build.publish failed to export: failed to push registry:5000/simcheckapi: failed to do request: Head "https://registry:5000/v2/<imagename>/blobs/sha256:b7611c82
โ”ƒ 6debba743ac3bd762e17f12658d285d9495fa7c9457daa71e74cef19": dial tcp: lookup registry on 10.87.0.1:53: no such host

how to get the name registry to resolve from the engine container?

If I use localhost it fails to connect as the container's localhost isn't the same.

I've tried running the registry connected to the engine network, but I'm not sure how kuberentes would then be able to pull the image. I've also tried using kind's network and making sure that the engine, registry and kuberentes control plane containers are all on this docker network, but to no joy.

Any help greatly appreciated.

open tulip
#

this way your Dagger pipelines can access services accessing in the host and vice-versa

cloud flint
#

Thanks I'll give it a go

#

still getting a dns issue

#

I added
// expose host service on port 5000
hostSrv := client.Host().Service([]dagger.PortForward{
{Frontend: 5000, Backend: 5000},
})

and change the build and publish to
ref, err := client.
Container().
WithServiceBinding("registry", hostSrv).
Build(workspace, dagger.ContainerBuildOpts{
Dockerfile: "Dockerfile",
}).Publish(ctx, "registry:5000/simcheckapi") //#nosec
if err != nil {
panic(err)
}

โ–ˆ โ”‚ [4.54s] ERROR go run main.go
โ”ƒ โ”‚ panic: input:1: container.withServiceBinding.build.publish failed to export: failed to push registry:5000/simcheckapi: failed to do request: Head "https://registry:5000/v2/simcheckapi/
โ”ƒ โ”‚ blobs/sha256:25377070ccedaa01f4c0004ce6be6aebf56c607f4eaab0b1195c30631d1e532c": dial tcp: lookup registry on 10.87.0.1:53: no such host
โ”ƒ โ”‚
โ”ƒ โ”‚
โ”ƒ โ”‚ goroutine 1 [running]:
โ”ƒ โ”‚ main.main()
โ”ƒ โ”‚ /mnt/c/source/Core/pipelines/main.go:45 +0x678
โ”ƒ โ”‚ exit status 2
โ”‚ โ–ˆ [0.47s] tunnel /upstream.5000.sock:5000/tcp
โ”‚ โ”ƒ 2024/01/12 15:08:29 listening on 5000/tcp
โ”‚ โ”ƒ 2024/01/12 15:08:29 10.87.0.17:58812 > handling
โ”‚ โ”ƒ 2024/01/12 15:08:29 10.87.0.17:58812 > dialed /tmp/.buildkit-ssh-sock2039998240/ssh_auth_sock
โ”‚ โ”ƒ 2024/01/12 15:08:29 10.87.0.17:58812 > copy upstream->downstream error readfrom tcp 10.87.0.22:5000->10.87.0.17:58812: use of closed network connection
โ”‚ โ”ƒ 2024/01/12 15:08:29 10.87.0.17:58812 > done
โ”‚ โ”ป
โ–ˆ [0.05s] ERROR publish(address: "registry:5000/simcheckapi", mediaTypes: "OCIMediaTypes")
โ”ป
โ€ข Engine: 17166920c44a (version v0.9.5)
โง— 20.67s โœ” 25 โˆ… 24 โœ˜ 2

#

here's the command to run the registry
docker run -d --rm --name registry -p 5000:5000 registry:2

cinder umbra
open tulip
cloud flint
#

Is this a major architectural change?

cinder umbra
#

I don't think so ๐Ÿ™‚ Just some missing plumbing.

#

The pieces are already there, we need to connect them.

open tulip
#

going back to this, I guess the workaround you could do for the moment is to launch another registry container with the dagger engine's --net flag and share the same underlying volume with the first registry container

#

so, docker run -v registry-data:/var/lib/registry -p 5000:5000 and then same thing but without the -p and --net container=$engine_container

#

that way you'll have two registry containers that will share the same underlying data volume

#

and in your pipeline you can Publish to localhost:5000 safely