I assume you must be knowing what is Docker, Container and their concept.
Here I am giving only basic steps to develop Docker Image for web based application. This tutorial will give you very basic temple on how to develop web based Docker Image.
Please use comment box if you have any question or suggestion.
Step 1: Create one HTML file, say index.html
This web page from Docker / Kubernetes
Current time
var dt = new Date();
document.getElementById("datetime").innerHTML = dt.toLocaleString();
Step 2: Create one Docker file
FROM centos:latest
RUN yum -y install httpd
COPY index.html /var/www/html/
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
EXPOSE 80
Step 3: Build Docker Image, use below command
docker build -t hello-web .
NOTE: one dot is there at last in above command. I assume index.html and Docker are in the folder that why I used dot else you can give path of Dockerfile as well.
Now your Docker Image ready to use. How to use:
docker run -p 3123:80 -it hello-web:latest
Here 3123 is host machine port and 80 port where application is running in container.
Go your web brower:
http://locahost:3123
You will get output, like some thing:
This web page from Docker / Kubernetes
Current time
10/12/2018, 11:58:36 PM
I have already push this image to docker hub, you can directly pull from there:
docker pull binodsuman/hello-web
docker run -p 3123:80 -it binodsuman/hello-web:latest
No comments:
Post a Comment
You can put your comments here (Either feedback or your Question related to blog)