Home  >  Article  >  Operation and Maintenance  >  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?

王林
王林Original
2020-05-21 14:46:114960browse

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

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

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!

Statement:
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