How to connect to a docker container from the outside world

I have a web application that is running inside docker container which is running on an Amazon Linux ec2 instance. I would like to connect to that container from the outside world.

How would I do this? I tried using the ec2 instance’s ip address and the port that is exposed, such as: 34.21.331.333:7070

  • Windows Container (Nano Server) with ASP.NET Core
  • Unable to reach Bash Shell on 'docker attach'
  • AutoScaling in Docker Containers
  • docker linking how can both containers know each others ip
  • Any suggestion for running Aerospike on Kubernetes on CoreOS on GCE?
  • Boot2Docker doesn't recognize “sudo”, “tce-load”
  • but this would just give me a 404 error.

    I also tried exposing the IP of the ec2 instance at run time, such as: docker run --name myapplication -p 34.21.331.333:7070:7070

    But docker gave me the error: bind: cannot assign requested address

    Any ideas?

    Thanks

    EDIT 1:

    I am able to connect now, resolved.

  • Nginx load balancer upstream SSL and Docker
  • Unable to start Docker in Windows 10 - Hyper-V error is thrown
  • docker-ce 17.06.0-ce failed to pull from private registry mirror
  • ECS Docker Container get env variable running cron
  • how to create docker overlay network between multi hosts?
  • How to answer command line prompts in script in docker
  • One Solution collect form web for “How to connect to a docker container from the outside world”

    In EC2, you have to check the security group for your instance and ensure that the port you want is opened to the world.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.