Home >Operation and Maintenance >Docker >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!