'Can't connect to apache webserver running in docker container on ec2

Can't connect to apache webserver running in docker container on ec2. Container was built from dockerfile:

FROM ubuntu:16.04

RUN apt-get -y update RUN apt-get -y install apache2 RUN echo 'Hello World from Docker!' > /var/www/html/index.html CMD ["/usr/sbin/apache2ctl", "-D","FOREGROUND"] EXPOSE 80

Then I run commands: docker build -t app1 . docker run -d -p 1234:80 app1:latest

curl from ec2 to 127.0.0.1:1234 or to private_ip:1234 or to docker_ip:1234 works fine But I can't open it through public_ip via browser from the internet.

Security_group allows traffic for 80,443,22 and 1234 port from anywhere. NACL allows everything I tested ports through ncat and machines can communicate through 1234 port...

I am ready to try any suggestions to resolve the issue!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source