Docker deployment ngnix static websites

Hello World

First get ngnix mirror (the default is the latest version,

docker pull nginx

First to write a simple Dockerfile, a Dockerfile modify the Nginx mirrored Home

Dockerfile is a text file containing a number of instructions, the instruction describes the construction details of the mirror.

1, the new folder / ngnix, create a new file named Dockerfile in the directory, in which the following additions:

# From a local warehouse lira take ngxin mirror image of docker 
 the FROM nginx 
modify ngxin of docker mirrored content Home # 
RUN echo 'the Hello World'> /usr/share/nginx/html/index.html

2, execute the following command in the path Dockerfile where to build our own ngxin mirror finish constructing command to view the available docker images

docker build -t nginx:rogn.

Which, -t specify a mirror name, the command final point (.) Represents the path Dockerfile file

3, the following command can be used to start the image a container Docker

docker run -d -p 92:80 nginx:rogn

4, visit localhost: 92 will be able to see the "Hello World"

A web page

First, access to source code: Address

In the foregoing, based on the modified Dockerfile,

Source file structure is as follows,

 

 COPY file one by one to the / usr / share / nginx / html folder.

# From a local warehouse lira take ngxin mirror image of docker
 the FROM nginx   
modify ngxin of docker mirrored Home Content # 
# RUN echo 'This IS Rogn Nginx !!!' > /usr/share/nginx/html/index.html  
 COPY index /usr/share/nginx/html/index.html .html 
 COPY home.html /usr/share/nginx/html/home.html 
 COPY navigation.html /usr/share/nginx/html/navigation.html 
 COPY CSS / usr / Share / Nginx / HTML / CSS
 COPY font / usr / Share / Nginx / HTML / font
 COPY Images / usr / Share / Nginx / HTML / Images
 COPY JS / usr / Share / Nginx / HTML / JS

Save, rebuild the mirror, starting container (if not stopped in front of the need to stop and start).

Renderings:

 

 

 

Reference links:

1. https://zhuanlan.zhihu.com/p/78295209

2. https://blog.csdn.net/github_39611196/article/details/78270999

3. https://yeasy.gitbooks.io/docker_practice/image/dockerfile/copy.html

Guess you like

Origin www.cnblogs.com/lfri/p/11621744.html