Meet Kaniko

So, what is kaniko?

Kaniko is a tool to build container images from a Dockerfile inside a container or Kubernetes cluster. Another great callout for me is that my CI provider, GitLab makes it super easy to implement in my pipelines.

Kaniko doesn't depend on a Docker daemon and executes each command within a Dockerfile entirely in userspace. This enables building container images in environments that can't easily or securely run a Docker daemon, such as a standard Kubernetes cluster.

How does Kaniko work?

The kaniko executor image is responsible for building an image from a Dockerfile and pushing it to a registry. Within the executor image, we extract the filesystem of the base image (the FROM image in the Dockerfile). We then execute the commands in the Dockerfile, snapshotting the filesystem in userspace after each one. After each command, we append a layer of changed files to the base image (if there are any) and update image metadata.

Highly recommend visiting their repo to find out more. GitLab's Kaniko reference URL

In summary, Kaniko will allow you to build and push images in a Kubernetes cluster without any special privileges or permissions and build them from a Dockerfile without access to a Docker Daemon because now we don’t need it anymore to build container images.

GitLab Support

As I mentioned, GitLab makes it easy to use out of the box with builds; just add Dockerfile. 

add your ci file

sample ci

Visit the GitLab template repo for additional details.



Popular

Federated user activity made easy

Google Cloud: Container Registry will be replaced by Artifact Registry