Home > Operation and Maintenance > Docker > What should I do if I cannot access nginx after docker starts it?

What should I do if I cannot access nginx after docker starts it?

王林
Release: 2020-05-21 14:46:11
Original
5064 people have browsed it

What should I do if I cannot access nginx after docker starts it?

Problem restoration:

Install the nginx image in docker, use the following command to create an nginx container and start it.

docker run --name nginx -d nginx
Copy after login

After startup, enter the IP address in the browser to access, but the access failed.

Cause analysis:

The mapping port parameter of port 80 is missing

The correct command is:

docker run --name nginx -p 80:80 -d nginx
Copy after login

Start the container again, in the browser The access can be successful.

Note: Even if the default port 80 listening container is used, the mapping port parameter of port 80 must be specified in the running command.

Recommended tutorial: docker tutorial

The above is the detailed content of What should I do if I cannot access nginx after docker starts it?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template