During development it often occurs that with local testing, docker is used for building and running container images. Then, when working with a local kubernetes cluster such as for instance k3d, you also want to test out kubernetes deployment. This requires the local k8s cluster to be able to access the images. Unfortunately, the docker deamon provides its own API and does not provide a registry API. So this setup requires you to run a separate registry (in a docker container) and push images after building them to the local registry after which k3d can access them.
The workflow typically looks like this:
- build docker image and test locally without kubernetes
- push docker image to local registry (e.g. at localhost:5000)
- run tests on local kubernetes cluster
The first step can be automated easily using docker compose and by tagging the images that to be of the form localhost:5000/<imagename>
. The second step is then docker compose push
. However, in practice it is really easy to forget to do the second step and this can cost some time for troubleshooting. Wouldn’t it be nice if we could make it work without having to push manually every time after building?
Continue reading