DEV Community

Cover image for Build docker images inside of Kubernetes
Mostafa Gazar
Mostafa Gazar

Posted on

5 3

Build docker images inside of Kubernetes

There are many reasons why we might want to build docker images inside of a Kubernetes cluster. Reasons are out of scope of this post but one reason might be to integrate them in you CI pipelines.

Build and push docker images inside of k8s as you please, on the other hand running containers can be very problematic. It is problematic because k8s will not know about these containers and will not be able to manage them. This just defeats the purpose of using k8s in the first place.

That said if you really need to run unmanaged containers on your own, consider creating a separate node pool just for that purpose.


Let us talk requirements, our requirements are basic:

  • We want to be able to build docker images in a specific pod.
  • Push images to a local registry or docker hub.
  • Caching would be nice-to-have, otherwise each are build would take a long time.
  • Finally, preferably we will use a daemonless docker build tool instead of installing docker inside a container and mount /var/run/docker.sock

A google search for "Daemonless docker builds" will return a few results like:


After all the research, I landed on using buildah with an insecure registry. Here are a few commands I used for testing

# debug building a dockerfile
buildah --debug bud -f Dockerfile -t mostafagazar/test .

# Without build args
buildah bud -f Dockerfile -t mlstudio-registry.default.svc.cluster.local:5000/test:v0 .
buildah push --tls-verify=false mlstudio-registry.default.svc.cluster.local:5000/test:v0

# With build args
buildah bud --build-arg model_name=name -f Dockerfile -t mlstudio-registry.default.svc.cluster.local:5000/test2:v0 .
buildah push --tls-verify=false mlstudio-registry.default.svc.cluster.local:5000/test2:v0
Enter fullscreen mode Exit fullscreen mode

Want to get early access to ML Studio and product updates? Subscribe here or follow me on twitter

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more