Preload/cache docker images

Docker Q …
I’m trying to cache a number of other docker containers on Codespaces. So that when the codespace image is started, the other containers are ‘instantly’ available.

I’ve gotten this to work in the postCreateCommand, but that happens after VS code has started and can still take a while…

Thus the image may not be available when a user start to use their codespace in earnest.

I tried to add
Docker pull image --quiet

To the docker file of the codespace, but that seems to lead to an infinite loop, eventually crashing the codespace creation.

From image
User codespace
Run docker pull image --quiet

If I’m understanding correctly, the docker image shouldn’t be preloaded on the containers, but on the containers host… Anyone have a better idea on how to preload/cache the image other than waiting for the container to start and then running docker pull?

Is there any way to guarantee on which codespaces host your codespaces instance is spun up? If not I don’t think there is any way to cache the images because there’s no guarantee that the next codespaces image is spun up on the host that has previously pulled the images.

No, but the codespace keeps running.

When I run docker pull some image:latest, inside of the codespace, that image is persisted, even when the codespace is stopped. It’s still available when the codespace resumes.

But adding the same command to the Docker file doesn’t seem to work.

Say I want to pre-pull the angular-cli image or a tfx-cli image or…

And I want te pre-pulling to happen before vscode is started… Doing it after, I know how to do.

Is it acceptable if the container is simply not-yet-ready while pulling, so the user cannot access it yet? In that case you could overwrite the exec command

The RUN command is executed during container building, not during container start-up, that’s why it’s not working.

You could use to run a custom script that pulls the images, and when done executes the normal startup behavior of the codespace.

Or the entrypoint: , I’m not clear on the specific differences anymore but depending on how the base image is built you need to use on or the other, or both I think.

Looks like you need to overwrite the ENTRYPOINT:

Can’t get that to work.

This is the only possible way I can think of, if that doesn’t work then idk