#`client.container().from()` but offline

1 messages · Page 1 of 1 (latest)

arctic compass
#

I have rather interesting problem to solve. I am using client.container().from() which works just fine when online, but fails for obvious reasons while offline. However it also fails when the Docker container was already retrieved (cached). I understand why, it is because it is trying to fetch the manifest and so on.

So my question is the - how can I make it so that my program can also work offline when the container was already fetched earlier. Is there a way to do this? The desired behaviour would be in case of from() fail just use the already present container.

I suppose one way would be to export it as tarball and then import it when the from() fails. But that is cumbersome at best. I looked into documentation and found stuff like ContainerID and ImageRef, but no way to actually use them.

hardy creek
arctic compass
#

Hi. Oh, I see. hmmm ....

#

Would be nice if it could be automated. Meaning person could put in like name:v1.0.0 and it would behave the same as digest

#

Can I get a the image digest from dagger?

#

Is that what ImageRef returns?

arctic compass
# hardy creek hi there! yes. If you use the full image digest like `name:sha256@$hash`instead ...

OK, I just tried it out and it seems that ImageRef is what I am looking for.

When I use some container, let's say name:tag the container.ImageRef() returns name:tag@sha256:.... So basically if I want to make this seamless for the user, I need to cache this string output of container.ImageRef() somewhere and then on-the-fly replace it in subsequent executions (of course only when the name:tag match)

hardy creek
arctic compass
#

🤔