主机端口映射不适用于EC2上的docker-compose

Kes*_*115 5 amazon-ec2 docker-compose

I tried to run this hello world app on an AWS EC2 instance with docker-compose up --build . It works as expected and is accessible remotely from the EC2 public IP when I use port 80 i.e., "80:80" as shown in the docker-compose file.

However, if I change to another port such as "5106:80", it is not accessible from a remote host using <public IPv4 address>:5106 even though it's available locally if I ssh unto the EC2 instance and try localhost:5106. Please note:

  1. I've ensured the EC2 is in a public subnet and I have configured the security group to make the port (in this case, 5106) accept inbound traffic from my laptop.

  2. I know it's not a problem with the hello-world app because I experience exactly the same problem with another app i.e., only port 80 works with docker-compose port mapping on EC2.

jua*_*ito 4

由于它适用于端口80并且不适用于端口,5106因此可能意味着以下两种可能性之一:

  • 您的安全组存在问题。您应该检查您是否已5106在您的inbound rules
  • 防火墙或防病毒软件存在问题,不允许您连接到不同端口(而不是80或 )中的网页443。如果其他设备或其他网络上发生这种情况,您可以尝试。

在这种情况下,似乎是后者。