Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试连接到EC2上的docker容器时,连接被拒绝_Docker_Amazon Ec2_Docker Compose_Port_Docker Networking - Fatal编程技术网

尝试连接到EC2上的docker容器时,连接被拒绝

尝试连接到EC2上的docker容器时,连接被拒绝,docker,amazon-ec2,docker-compose,port,docker-networking,Docker,Amazon Ec2,Docker Compose,Port,Docker Networking,我目前正在EC2上的docker容器中运行spring引导应用程序。我的docker compose文件如下所示(替换了一些值): docker容器部署并显示为健康状态,healthcheck命令为: wget --spider -q -Y off http://localhost:8893/my-app/v1/actuator/health 如果我使用docker ps-a,我可以看到端口: 0.0.0.0:8893->8893 但是,我的Alb healthcheck返回502,因

我目前正在EC2上的docker容器中运行spring引导应用程序。我的docker compose文件如下所示(替换了一些值):

docker容器部署并显示为健康状态,healthcheck命令为:

wget --spider -q -Y off http://localhost:8893/my-app/v1/actuator/health
如果我使用docker ps-a,我可以看到端口:

0.0.0.0:8893->8893
但是,我的Alb healthcheck返回502,因此我暂时允许从我的IP直接连接到安全组中的EC2。这些规则是:

Allow Ingress on 8893 from my Alb security group
Allow Ingress on 8893 from my IP
Allow Egress to anywhere (0.0.0.0)
当我尝试使用Postman在端口8893上使用ec2的公共DNS点击我的应用程序的healthcheck端点时,我得到错误:connect EconRefused

如果我取下docker容器,然后使用以下命令模拟Web服务器:

while true; do { echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n<h1>hello world from $(hostname) on $(date)</h1>" |  nc -vl 8080; } done
为true时;do{echo-e“HTTP/1.1 200 OK\r\n$(日期)\r\n\r\nhello world from$(主机名)on$(日期)”| nc-vl 8080;}完成
我得到了预期主体的200响应,这表明安全组没有问题

spring boot的执行器端点已明确启用,就好像我尝试通过intellij运行应用程序并点击端点一样,它返回一个200,状态为up


对于我在这里可能缺少什么或者如何进一步调试,有什么建议吗?docker似乎出于某种原因没有连接到端口。

容器是否在本地开发环境中运行(AWS安全组不受关注)?您可以从EC2实例上的ssh会话连接到容器吗?看起来没有,但我得到的是“错误:套接字挂起”,而不是本地拒绝连接。稍后将试用EC2
while true; do { echo -e "HTTP/1.1 200 OK\r\n$(date)\r\n\r\n<h1>hello world from $(hostname) on $(date)</h1>" |  nc -vl 8080; } done