Docker multi stage builds, Kubernetes, and Distroless compatibility

9/18/2018

I am facing "theoritical" compatility issues when using distroless-based containers with kubernetess 1.10.

Actually, distroless requires docker 17.5 (https://github.com/GoogleContainerTools/distroless) whereas kubernetes does support version 17.03 only (https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.10.md#external-dependencies)

  1. is it possible to run distroless containers within kubernetes 1.10 clusters w/o any issue?
  2. is it possible to build distroless based images on a build server running docker 17.05 then deploying it on a kubernetes 1.10 cluster (docker 17.03)?
-- Jack Admin
docker
kubernetes

2 Answers

9/19/2018

The requirement for 17.05 is only to build a "distroless" image with docker build using multistage Dockerfile. When you have an image built, there is nothing stopping it from running on older Docker / containerd versions.

Docker has supported images with no distribution for ages now by using FROM: scratch and leaving it to the image author to populate whatever the software needs, which in some cases like fully static binaries might be only the binary of the software and nothing more :)

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

9/19/2018

It seems that you might need Docker 17.05+ only for building images using multi-stage files.
After you build an image with the multi-stage Dockerfile, it will be the same image in the registry like if you build it in an old-fashioned way.

Taken from Use multi-stage builds:

With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image.

The end result is the same tiny production image as before, with a significant reduction in complexity.

Kubernetes does not use Dockerfiles for creating pods. It uses ready to run images from the Docker registry instead.

That's why I believe that you can use such images in Kubernetes Pods without any issues.

But anyway, to create and push your images, you have to use a build machine with Docker 17.05+ that can consume new multi-stage syntax in the Dockerfile.

-- VAS
Source: StackOverflow