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
Insert picture description here
search found that there is an nginx mirror, we can download it directly.

2. Download the nginx mirror

command:

docker pull nginx

Screenshot:
Insert picture description here
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:
Insert picture description here
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.
Insert picture description here

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:
Insert picture description here
As shown in the figure, after we have added the container, we can modify the configuration file by entering the /etc/nginx directory.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43520670/article/details/113501983