docker start nginx unable to access port 80 under linux

problem:

Linux installed docker, docker launched a nginx container through port 80 can not normally access

Troubleshooting:

1, container inspection nginx start command or yaml file to see if there are binding with the local port

Start nginx container when the local port 80 (the same reason other ports) need to be bound with 80 ports nginx container (can be other port binding), so access to the local port 80 to the normal jump to the corresponding container nginx the port

2, after the container is up and running:

docker ps -a

Binding situation View the container start-up state and the corresponding port

3, view usage linux port, run:

netstat -ntlp

View linux corresponding port (port 80) whether the processing status of normal listening

4, see the firewall, run:

iptables -nvL

See if there are 80 ports, if not, the steps were 4.1, 4.2

  4.1, if there is / etc / sysconfig / iptables this document on view linux, yes, vim to modify, to see if there are 80 ports, plus no words

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

  Above this line of code in the "-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT" on the line after the line, meaning that the port 80 is exposed

  After modifications are complete, restart the firewall, run:

service iptables restart

  4.2, may later part CentOs7 linux machine does not have / etc / sysconfig / iptables this document, then run directly:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

Tips: After the restart iptables, to restart under docker, restart your nginx container

systemctl restart docker

5, whether there is a port corresponding to the host if the cloud, but also look to the ECS corresponding security group (the network configuration)

 

Guess you like

Origin www.cnblogs.com/lyc94620/p/11783080.html