Docker actual deployment of nginx
The combination of learning and practice is not easy to forget, deploying nginx is a practice of mine
1. Find the nginx mirror
If you can find it, you can download it, and then run the
command:
docker search nginx
Screenshot: The
search found that there is an nginx mirror, we can download it directly.
2. Download the nginx mirror
command:
docker pull nginx
Screenshot:
Successful download!
3. Run the nginx image and access it through the external network
command:
docker run -d --name nginx -p 8003:80 nginx
Screenshot:
Explanation:
- -d means running in the background
- -Name Specify a name for nginx (nginx can be operated by name later without id)
- -p 8003:80 maps port 80 of docker through port 8003 of the host
4. Test
Enter ip+port or domain name+port in the browser to access. The following figure represents a successful test.
5. Enter the configuration file of the nginx container
Sometimes we need to enter the container to modify the configuration file, we have to look at the following
command:
docker exec -it nginx /bin/bash
Screenshot:
As shown in the figure, after we have added the container, we can modify the configuration file by entering the /etc/nginx directory.