JasonRivers / Docker-nginx-rtmp

Docker Image for RTMP streams using Nginx
180 stars 114 forks source link

Multiple Containers with Different ports #9

Closed coffeebean-dev closed 6 years ago

coffeebean-dev commented 6 years ago

I'n not sure if this is possible with nginx or not, but is it possible to have multiple containers running with different ports? Basically I need a way to add and destroy multiple streams on the fly. Currently, I just create a single container with multiple streams, but this isn't going to work in the long run since I need to be able to add and remove streams on the fly.

JasonRivers commented 6 years ago

Absolutely! When you run the container, simply change the port that you want to listen on, I'll assume it's only RTMP you're interested in for the example, but if you're using HLS, too - then simply bump the port on that, too:

## stream1
docker run -p 1935:1935 jasonrivers/nginx-rtmp
## stream2
docker run -p 1936:1935 jasonrivers/nginx-rtmp
## stream3
docker run -p 1937:1935 jasonrivers/nginx-rtmp

when streaming to this you can then use rtmp://{IP}:1937/live/stream to stream to the stream 3 container

For most of the work we do, we have a separate container for each stream, this allows us to push each stream to a different twitch/youtube account.

Hope this helps!

coffeebean-dev commented 6 years ago

That's exactly what I was looking for. I also see what I was doing wrong.

I was updating both ports like so:

docker run -p 1936:1936 jasonrivers/nginx-rtmp

Thanks for your quick reply!