In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. Environmental description
Docker: 18.03.1-cenginx: 1.15.1
2. Pull the latest Nginx image
Pull the image
$docker pull nginx
View the current image
$docker images# query result: REPOSITORY TAG IMAGE ID CREATED SIZEnginx latest 8b89e48b5f15 7 hours ago 109MB
III. Preparatory work
This time, deploy the web service under / srv/web directory:
3.1 create the / srv/web directory and enter it
$cd / srv & & mkdir web & & cd web
Create a random Nginx container and copy the default configuration of Nginx:
Create a container:
$docker run-d-- name nginx nginx copy the configuration file from the container to the local: # View = > get the container ID$ docker container ls# create directory under the current directory: conf $mkdir conf# copy the Nginx default configuration file in the container to the local conf directory under the current directory $docker cp a89b2c5f3dd1:/etc/nginx/nginx.conf $PWD/conf delete container: # stop container $docker container stop a89b2c5f3dd1# delete container $docker container rm a89b2c5f3dd1
IV. Start formal deployment
Deployment commands:
$docker run-d-p 8081 PWD/html:/usr/share/nginx/html 80-- name nginx-web-6666-v $PWD/html:/usr/share/nginx/html-v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf-v $PWD/logs:/var/log/nginx nginx command details:-d # indicates that the container has been running in the background-p 8081 PWD/html:/usr/share/nginx/html 80 # to map the port Map local port 8081 to port 80 inside the container-container name created by name # setting-v # mount local directory (file) to container specified directory
5. Testing
5.1 Test
opens if it is a local test deployment: localhost:8081 can access the web server
5.2 add:
mounts the root directory of the nginx in the container to the local specified directory, so the page visited above should report a 403 error. Next, we can start our project at / srv/web/html/.
5.3 enter the local directory: / srv/web/html/ to create the test file index.html
$cd / srv/web/html# create and randomly write content to refresh the page $vim index.html
Summary
The above is the method of installing Nginx under docker introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message for me, and the editor will reply you in time. Thank you very much for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.