Though I can run ubuntu container in k8s:

 $ k run ubuntu -it --rm --image ubuntu -- bash

But this image has very few commands for system admin and development.

So I have to build an image for myself which has the basic commands for DevOps stuff.

Here is my customized content in Dockerfile:

 FROM ubuntu
RUN apt update && apt -y install \
make cpanminus git iputils-ping dnsutils wget curl mysql-client libdbd-mysql-perl net-tools
RUN cpanm MySQL::mycrud

Before 'docker build' I have to setup the correct DNS entries for Docker.

Create the file /etc/docker/daemon.json and put the content into it:

"dns": ["", ""]

And restart docker daemon:

 $ sudo service docker restart

Next run docker build:

 $ docker build -t myubuntu myubuntu/

Surely Dockerfile should be put under "myubuntu/" dir.

After successful building I could tag it for release ready.

 $ docker tag myubuntu geekml/myubuntu:latest

Run 'docker login' to log into docker hub, after then we can publish the image to the official hub.

 $ docker push geekml/myubuntu:latest

Now run the image from k8s:

 pyh@kube:~$ k run myubuntu -it --rm --image geekml/myubuntu -- bash
If you don't see a command prompt, try pressing enter.

root@myubuntu:/# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

All are doing well.

Return to home | Generated on 03/07/23