tomcat on docker container on linux mapped to anything other than 8080 is not accessible from internet

Viewed 47

I tested AWS EC2 Amazon Linux and Ubuntu 18.04. Tomcat is reachable from localhost:8081, but not from outside network

After pulling thee tomcat image

docker pull tomcat

Then running a container with port mapping:

docker run -d --name container-test -p 8081:8080 tomcat

Tomcat web page is not accessible, says:

This site can’t be reached 13.49.148.112:8081 took too long to respond.

But if doing this way, it's working fine.

docker run -d --name container-test2 -p 8080:8080 tomcat

I opened ALL ALL ALL in AWS security groups.

netstat shows that ports are listening correctly

ACLs are at default rule 100 allowing everything

I also did nmap this and found out the port is filtered:

$nmap -p8081 172.217.27.174
   PORT     STATE    SERVICE
8081/tcp filtered blackice-icecap

Tried to add a rule to iptables but no luck:

iptables -I INPUT 3 -s 0.0.0.0/0 -d 0.0.0.0/0 -p tcp --dport 8081 -m state --state New -j ACCEPT

What can be done?

UPDATE: Spent 2 good days to solve the issue with Amazon Linux2, but no success at all, switched to Ubuntu 22.04 and it's working. Also, same setup works on diff ami image in Mumbai region, hence there is a high chance the image is faulty in Stockholm region specifically.

1 Answers

could be one of this:

  • check the port mappings of the container of your task definition
  • check the entries of the NACL (access control list) of your subnet (check if its public)
  • check if you allowed the trafic in the security group for your ip or 0.0.0.0/0
Related