In theses series of the blog, I will show you how to “dockerize”, “kubernify” and monitor an application. It will probably be broken down in 3 major parts, so stay tuned.
In this first part, we will create a Docker image of an nginx web server that serves a “Hello World” page.
Then, in this 2nd part, we will setup our ‘mini’-kubernetes cluster and host our app on it.
And in the 3rd part, we'll see how we can set up our app to be fault-tolerant and highly available
The first prerequesite is an Unix-like OS, working with Docker and K8s on Windows is a pain in the ass 🤕. If you don't have a Linux or a MacOS OS, go ahead and make yourself a VM of CentOS or Ubuntu. You should now install these programs:
Follow along the instructions and if you stumble upon any issues, feel free to reach out to me.
1. Dockerize some!
Felt like I had to put this in.
2. Building the Docker image
Let's start by laying off our
Create a file called
Dockerfile in a directory of your choice. This will be its content:
FROM nginx:stable-alpine RUN echo "Hello World!" > /usr/share/nginx/html/index.html
‘nginx:stable-alpine’ This will be the base image of our app.
RUN echo "Hello World!" > /usr/share/nginx/html/index.html We will then overwrite the default homepage served by nginx. To not complicate things, we will just print a “Hello World” message in.
Build the Docker image by running
docker build -t nhw .. ‘nhw’ is the name I chose to give to my image (Nginx Hello World 😉).
docker images will list you all the Docker images you have on your localhost, including the latest built one: ‘nhw’.
3. Running the Dockerized application
Next, we'll run the image that we just built AND we'll map the port at which the application is listening (80) to an open port on the localhost (in my case 81). Let's run
docker run -d -p 81:80 nhw
docker ps to check that your container is effectively up and running.
Now let's ask our app to send us some info! Run
The response is just… beautiful 🥺
In the next blog, we will create a minikube cluster and we'll deploy this dockerized application in it.