

Deploying a Static Website In a Container and Ship it any Anywhere
source link: https://dev.to/nipun214/deploying-a-static-website-in-a-container-and-ship-it-any-anywhere-4b68
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.


Posted on Oct 27
Deploying a Static Website In a Container and Ship it any Anywhere
What is Docker?
Ans: Docker is a set of platform as a service products that use virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files.
Steps that we are going to perform:
- Creating Docker file
- Create an image of our static website with use of Docker file
- Push that image to Docker Hub
- Run that container on Server
Creating Docker File:
FROM nginx:latest
COPY . /usr/share/nginx/html
EXPOSE 80
CMD [“nginx”,”-g”,”daemon off;”]
FROM — is where we are pulling our official image from nginx is an official image provided by Docker
COPY — is taking our all file from out local directory were are working in and moves it into the /usr/share/nginx/html directory(of NGINX) in our container.
EXPOSE- is a instruction letting the container know we are exposing the port 80 (TCP)
CMD- provide defaults for an executing container
Create an image of our static website with use of Docker file:
For that we have to execute command and that is:
docker build -t "<name of image you have to put>" .
This command means :
-t = Tag
"" = your image name
. = it will take dockerfile form present location.
So in my case, I am going to give image name as nipun2020/docker-community-rajkot
command will be for me :)
docker build -t nipun2020/docker-community-rajkot .
Push that image to Docker Hub
To push our image in docker hub for that we will use this command
docker push
in my case it will be ->
docker push nipun2020/docker-community-rajkot
Run that container on Server
Login into your server and make sure docker is installed on your server.
and just hit this command and your container will be running on your server.
docker run -p 80:80 nipun2020/docker-community-rajkot
So by use of this command your static website will be running with the use of Docker.
Demo of static site is hosted:
Thank you for reading this blog, hope you learned some new thing.
If, you have any doubt you can contact me on LinkedIn
LinkedIn: https://www.linkedin.com/in/nipun-parekh-6006a0152/
Recommend
-
26
serve is a static http server anywhere you need one. TL;DR It's basically python -m SimpleHT...
-
62
README.md ...
-
32
Deploying a Static Website on AWS Web Hosting with GitLab CI March 03, 2020 ...
-
13
Deploying Your Static Websites to AWS in Style Using Github Actions📅 December 09, 2019 – Kyle GalbraithGitHub Actions is gaining popularity for its simplicity and for the fact that a ton of repositories live in GitHub already....
-
9
Developing and deploying a whole website in Go (Golang) November 05, 2018 Reading time ~9 minutes In my opinion Go...
-
12
-
5
Deploying Blazor WebAssembly into Azure Static Web Apps Posted by Muhammed Saleem | Updated Date Jan 19, 2021 |
-
15
Generating a Static Site with Flask and Deploying it to NetlifyThis tutorial looks at how to leverage the JAMstack with Python and Flask. You'll lea...
-
8
Developing and Deploying a Static Web App with Blazor and Azure Functions506 viewsNov 16, 2021 Blazor...
-
9
Introduction As part of the .NET Advent Calendar I thought I'd try something new and after a suggestion on Twitter I decided that I would investigate basic uses of Pulumi to deploy to Azure. As...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK