Nginx, stylized as NGINX or nginx or NginX, is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. This can be used to host web Applications.
In this lab exercise, you will learn how to create a simple web App, Create an Nginx container and deploy that App into the container. And view the results on your browser
Prerequisites:
Install Docker
Step 1: Create the web App(HTML)
Log into your docker machine
Create the Html file using Vi Editor
$ vi index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Smashing Champions Web App!</title>
</head>
<body >
We are champions
we are champions!
</body>
</html>
Copy the Above code and paste on the editor. You can edit the body section as u please
Step 2: Create Dockerfile
open vi editor and copy the below code
$ vi Dockerfile
#FROM is the base image for which we will run our application
FROM nginx:latest
# Copy files and directories from the application
COPY index.html /usr/share/nginx/html
# Tell Docker we are going to use this port
EXPOSE 80
The above Docker file will create a base image from centos6 operating system, install nginx web server on it, then Copy the index.html file we created into "/usr/share/nginx/html" folder of the centos container. The image will be exposed in Port 80
Step 3: Create the docker image: You can tag it with -t , tag it any name you want. but we will use webapp
$ docker build -t webapp .
List docker images
$ docker images
Place your image id in place of highlighted yellow
$ docker ps -a
No comments:
Post a Comment