无法访问 nginx docker 容器

无法访问 nginx docker 容器

apache 安装在主机上。

nginx docker 容器使用 -p 8080:80 -p 4433:443 创建

# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                                         NAMES
dcd5ede93662        peratik/nginx       "nginx -g 'daemon of…"   26 minutes ago      Up 6 minutes (unhealthy)   0.0.0.0:8080->80/tcp, 0.0.0.0:4433->443/tcp   nginx

#netstat -tlpn
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp6       0      0 :::443                  :::*                    LISTEN      79008/httpd         
tcp6       0      0 :::80                   :::*                    LISTEN      79008/httpd         
tcp6       0      0 :::8080                 :::*                    LISTEN      78854/docker-proxy  
tcp6       0      0 :::4433                 :::*                    LISTEN      78868/docker-proxy  

nginx 正在运行:

# docker exec -it nginx nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# docker exec -it nginx service nginx status
[ ok ] nginx is running.

问题:

  1. 在容器内部我无法访问端口 80:
  2. 从外面(互联网)我也无法打开http://[ip]:8080

# docker exec -it nginx curl http://localhost curl: (7) Failed to connect to localhost port 80: Connection refused

请指教谢谢

答案1

我认为 ipv4 与 ipv6 套接字绑定有问题。

docker port forwards 报告 ipv4 addr,而 netstat 输出仅报告 ipv4 addr。

相关内容