NodeJS Hello World application with Docker and Kubernetes
Excute the below command from the root directory to create the docker image.
$ docker build -t abhishekjv/nodejs-hw .
Note: With -t
tag, I have specified the name of the image which also contains the name of my Docker hub ID. This is one of the best practice to follow when tagging images.
To run the application, execute the below command:
docker run -p 3000:3000 IMAGE-ID
docker push abhishekjv/nodejs-hw
kubectl create -f pod-nodejs-docker-hw.yml
kubectl port-forward nodejs-docker-hw 8081:3000
curl http://localhost:8081
kubectl expose pod nodejs-docker-hw --type=NodePort --name nodejs-hw-service
kubectl describe service nodejs-hw-service
Look for the port number defined for NodePort.