How to write dockerfile for installing kubeadm and kubectl

9/23/2019

We are facing error while deploying an application through dockerfile. While installing the Kubernetes (Kubectl, Kubeadm) through dockerfile, the client version is installed but the error while installing the server version i.e., kubeadm installation. The resultant screenshot is attached. It would be great if any one helps me to solve the issue. Kindly provide the document to install kubernetes via dockerfile.

enter image description here

-- Abhishek
docker
kubernetes

1 Answer

9/23/2019

My guess you want to create kubernetes cluster in docker environment, this is possible but your approach might not as good as you think.

There is KinD for that. It is actually what you want.

However if you still want to use your implementation. You should use DinD as base image, bind volume to local docker then use kubeadm in dockerfile as "CMD" not as "RUN".

-- Akın Özer
Source: StackOverflow