dokku / dokku-mongo

a mongo plugin for dokku
MIT License
177 stars 32 forks source link

canonical approach to accessing mongodb from outside of dokku #72

Closed miraculixx closed 8 years ago

miraculixx commented 8 years ago

this is related to the closed issues #56 and #39 - however these issues don't specify the specific steps other than using the expose command.

My scenario is to run multiple mongodbs (i.e. in dokku terms, multiple mongodb instances) on one dokku host. What is the recommended approach to exposing multiple instances to outside of the dokku host?

  1. open respective ports on the host directly
  2. use nginx e.g. with the stream module or the nginx mongodb plugin
  3. some other option?

In light of multiple mongodbs, option 1 seems impractical. I'm very much interested to hear from others about their experiences.

josegonzalez commented 8 years ago

You can use the following command to expose the ports to the outside world:

dokku mongo:expose SERVICE

By default, it will pick random ports to expose onto. The order in which the ports correspond to mongodb are thus:

You can also specify the port you wish to expose it on:

dokku mongo:expose SERVICE 1025 1026 1027 1028

Which again correspond to the aforementioned order.

There is no other way to expose an instance outside of the dokku host, nor do I have any desire to make services public by default.

miraculixx commented 8 years ago

@josegonzalez thank you for the detailed answer, much appreciated

nor do I have any desire to make services public by default.

absolutely agree with this statement. would you consider adding e.g. a --public option to this and and other plugins' expose command? alternatively is there a canonical dokku-way to open/close public ports?

josegonzalez commented 8 years ago

The expose command already makes the ports public. Once you run that, you'll be listening to both an internal IP:PORT as well as 0.0.0.0:SOME_PORT.

josegonzalez commented 8 years ago

When running dokku mongo:expose, we now show which ports are exposed where. This information is also available with dokku mongo:info SERVICE --exposed-ports.