Search code examples
amazon-web-servicesdockeramazon-ec2aws-ecr

Assigning IP Address to Docker Container on EC2


I am currently trying to get my docker container to be publicly addressable so I can route it through aws route 53 (DNS). I have my contained on an ubuntu ec2 and am looking for what I should do next. Here is the screenshot of my containers running on the instance.

enter image description here

Should I try to route these through nginx like normal or can I point them directly to an IP address through something like elastic IP on aws. Thank you!


Solution

  • For static public IP for your instance, elastic ip should be used.

    To ensure connectivity to your docker containers, please double check:

    • if security group(s) on the instance allow inbound traffic to the ports of interest.
    • same, please check network ACL on your subnet if they do not block the connections - both inbound and outbound.
    • ensure that the instance is in a public subnet and is reachable from the internet.
    • check if you can connect to the containers from inside of the instance, to make sure that your application is working as expected

    Alternatively, if you do not want to manage the instance and docker yourself, you can look into using AWS Fargate or Amazon ECS which will greatly simply management of your containers.