docker run -p or the Docker Compose
ports: section to expose your application via a port on your host system. Set the DNS name to point at the host.
This is slightly inconvenient if you want to host a plain Web application and otherwise have the power to make
http://myapp.example.com work; you’d prefer to not have to qualify it with a specific port number. In that case you need some intermediary that can answer that DNS name on port 80/443 and forward it to the right port on the physical host. In AWS I’d use an ordinary load balancer for this; I think it’s also pretty common to set up nginx or another Web server to do host-based routing.
My two pieces of advice are to not try to give your container an independently-accessible IP address (you will wind up reinventing most of the Docker networking machinery by hand and probably hard-coding IP addresses, which invites trouble) and to not touch
/etc/hosts anywhere at all (you said the magic words “DNS name” which is the right answer).
For AWS specifically, setting up an ordinary EC2 instance, installing Docker on it, publishing a port as normal, then setting up a load balancer in front of it and setting up a Route 53 DNS name to point at the load balancer is pretty routine. This is also the recommended setup for Amazon’s EC2 Container Service, but you don’t necessarily need to buy into ECS to do it.