In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to install nginx in docker, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
1. Use the docker images command to view the currently owned images, and use the docker pull nginx command to pull the images from the remote repository.
2. Create a directory that needs to be mapped to the nginx container (the so-called mount). The following is the directory structure I created, which needs to be mapped to the nginx container so that we can share the resources of the directory between the local machine and the container.
3. Use the docker command docker run-p 80:80-- name nginx-d nginx to run nginx, use the docker exec-it container id / bin/bash to enter the nginx container, and you can browse the configuration of / etc/nginx/; then use the exit command to exit the container; use the cd command to cut to the / nginx/conf directory, and then use the command docker cp container id:/etc/nginx/*. / copy the default configuration file of nginx.
4. Then find the nginx.conf file and add a static resource configuration path (Note: this path is configured with the container root path. Configure the local directory, you will not find a 404 error when accessing). In my configuration, my configuration is like this. Root configuration needs to be the path of the container rather than local, and save it after editing.
5. Then execute the command to create the container as follows: docker run-p 8081 docker_data/data/nginx/html:/usr/share/nginx/html 80-- name nginx-80-v / docker_data/data/nginx/html:/usr/share/nginx/html-v / docker_data/data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf-v / docker_data/data/nginx/conf/conf.d:/etc/nginx/conf.d-v / docker_data/data/nginx/logs:/var/log/nginx-d nginx
The general meaning of an order
-p 8081 80 runs a container local 8081 port maps container 80 port
-- name nginx-80 container name
-v / docker_data/data/nginx/html:/usr/share/nginx/html local directory mapping container directory (this is important, if the mapping is not correct, it will not be accessible) other-v configurations are mapping paths
-d nginx indicates that the container is running as a waiting process.
After execution, you can use the docker ps command to view the running container and access your own configured mapping path through the browser to see if you can access it successfully.
This is the answer to the question about how to install nginx in docker. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.
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.