Skip to content

A simple website using Nginx with the help of docker

Notifications You must be signed in to change notification settings

vyjith/simple_nginx_website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Nginx website Containerization (Docker)

Builds

Description

Creating a nginx website with the help of Dockerfile


Feature

  • A simple Docker file for image creation
  • Usage of Alpine OS as base image to reduce the size of image that built.

Prerequisites


  • Need to have Docker installed in your machine
  • Need to have Git insalled in your machine

Insallation


How to build an image with Dockerfile

Steps:

yum insall docker -y
systemctl start docker
yum install git -y
git clone https://github.com/vyjith/simple_nginx_website
cd simple_nginx_website
docker build -t <your_name_image:tag> .
#eg: docker build -t simple_nginx:10 .
docker image ls <-------------------------------------------------- image will list here 
docker run --rm -d -p 8080:80 simple_nginx:10  <-------------------------------------------------- Here we are running the image on port 8080
command line exaplation of docker run command
--rm                             Automatically remove the container when it exits
-p, --publish list                   Publish a container's port(s) to the host
-d, --detach                         Run container in background and print container ID

Please find the below screenshot of the Docker building an image.

alt text


You can see that the below docker images (docker image ls) alt text


creating a container from the image simple_nginx:10

alt text


Docker file explantion

# Dockerfile

FROM nginx:alpine   <-------------------------------------------------- Base image

WORKDIR /usr/share/nginx/html   <-------------------------------------------------- Image working directory

COPY . /usr/share/nginx/html/   <-------------------------------------------------- Copying the index.hmtl file to the Working directory

Conclusion

The intention of this Repository is to create awareness about the Dockerfile and the usage of containerization.

Please reach out to me if you have doubts regarding this. Thank you...

⚙️ Connect with Me

About

A simple website using Nginx with the help of docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published