Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing multiple ports from Docker within Elastic Beanstalk

From reading the AWS documentation, it appears that when using Docker as the platform on Elastic Beanstalk (EB) (as opposed to Tomcat, etc.), only a single port can be exposed. I'm trying to understand why Amazon created this restriction -- seems that you now can't even serve both HTTP and HTTPS.

I'd like to use Docker as the container since it allows me to run several interconnected server processes within the same container, some of which require multiple ports (e.g. RTSP). Are there any workarounds for this kind of application, where say an RTSP and HTTP server can both be running within the same Docker container on EB?

like image 938
thinkski Avatar asked Sep 14 '14 01:09

thinkski


People also ask

Can I expose multiple ports Docker?

In your Dockerfile , you can use the verb EXPOSE to expose multiple ports.

How do you expose multiple containers on the same port?

The most widely suggested workaround is to use an extra container with a reverse proxy like Nginx, HAProxy, Envoy, or Traefik. Such a proxy should know the exact set of application containers and load balance the client traffic between them.

How do I get Docker exposed ports?

Need of exposing ports. In order to make a port available to services outside of Docker, or to Docker containers which are not connected to the container's network, we can use the -P or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world.

How does Docker exposing ports work?

What Is Docker Expose Port? This tells Docker your webserver will listen on port 80 for TCP connections since TCP is the default. For UDP, specify the protocol after the port. For more than one port, you can list EXPOSE more than once.


1 Answers

Even though none of the documentation explains it, Single Container Docker Environment does support mapping multiple ports

{     "AWSEBDockerrunVersion": "1",     "Ports": [         {             "ContainerPort": "8080"         },         {             "HostPort": "9000",             "ContainerPort": "8090"         }     ] } 

With above configuration, port 8080 of docker will get mapped to host machines port 80 and port 8090 of docker will get mapped to host machine's port 9000.

To be more clear always the first port in the list will get mapped to host machine's port 80 and remaining will get mapped to specified hostPort (or) the same as container port in absence of host port.

like image 175
Prabu Avatar answered Sep 18 '22 13:09

Prabu