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

Expected behavior

Tomcat web page should open immediately on hostname(public IP):8081

Actual behavior

Tomcat web page isn’t reachable on hostname(public IP):8081

Additional Information

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

I opened ALL ALL ALL inbound traffic in corresponding AWS security groups.

ACLs are at default rule #100 allowing everything

Did nmap and found out the port 8081 is filtered:

$ nmap -p8081
8081/tcp filtered blackice-icecap

Tried to add a rule to “iptables” but no luck:

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

Steps to reproduce the behavior

  1. Launch Amazon Linux EC2 instance
    and connect to CLI

$yum update -y

$yum install docker -y

$service docker start

$docker pull tomcat

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

Try to access tomcat web page on

hostname(public IP):8081

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.