Hi there, I wanted to know what my options were for pre-caching container images before I run my dagger function, e.g. if I'm doing dag.container.from("mycontainer:1.0.0").withExec(...) I want to ensure mycontainer:1.0.0. doesn't need to be pulled as part of running the function. From some basic testing it doesn't appear the dagger engine uses images from the host Docker engine. I've seen the docs on custom runners and wasn't sure if that's my best option? Any advice would be greatly appreciated!
#Pre-caching container images
1 messages · Page 1 of 1 (latest)
Hi! You're right that the Docker Engine's image cache is separate from the Dagger Engine image cache.
When you run your function that refers to a container image, it will pull it the first time if not in cache and then it will be in cache for subsequent invocations.
If you wanted to load up the cache ahead of time for a given Dagger engine, you could just run a prep function or a script like
#!/usr/bin/env dagger
container | from nginx:1.27.5
container | from postgres:latest
#container | from mycontainer:1.0.0
Ah yeah that's nice and simple, thanks!
Hi Jeremy, just to give a little more context on what I'm trying to achieve - my dagger function is using a container image from a private (authenticated) registry but I want to be able to run the function on a host that has not logged into the registry and just rely on the image cache. Even though I have pre-cached the image, I still get a 401 when trying to use the container for example:
docker login my.registry
container | from my.registry/my-container:1.0.0 # Succeeds
docker logout my.registry
container | from my.registry/my-container:1.0.0 # Fails with unauthorized error
Any thoughts on whether I'm doing something wrong?
yes, we're using the docker login credentials (as you noticed) to pull the image, but I think also to check the digest. Seems like we need an option to "not check".
Can you try using the full image version hash/digest?
docker images --digests
Like
dagger -c 'container | from postgres@sha256:304ab813518754228f9f792f79d6da36359b82d8ecf418096c636725f8c930ad'