davidfowl / Micronetes

Micronetes is a local orchestrator inspired by kubernetes that makes developing and testing microservices and distributed applications easier.
MIT License
773 stars 46 forks source link

Add port mapping for Docker containers #45

Closed nj0yeh closed 4 years ago

nj0yeh commented 4 years ago

Please add the possibility to specify an internal and an external port for Docker containers. We run multiple MySQL Docker containers (that all listen to port 3306) and want to expose them to different external ports.

You can achieve this by replacing the second port in $"-p {p.Port}:{p.Port}" with the internal port.

davidfowl commented 4 years ago

Yep, this makes sense.

davidfowl commented 4 years ago

This looks a bit verbose:

- name: web
  dockerImage: davidfowl/web
  bindings: 
    - port: 5000
- name: api
  dockerImage: davidfowl/api
  replicas: 2
  bindings: 
    - port: 5001
      internalPort: 80

I could support the docker style syntax.

- name: web
  dockerImage: davidfowl/web
  bindings: 
    - port: 5000
- name: api
  dockerImage: davidfowl/api
  replicas: 2
  bindings: 
    - port: "5001:80"
nj0yeh commented 4 years ago

Since the internalPort is optional, I would vote for the first one for readability.

davidfowl commented 4 years ago

Fixed in https://github.com/davidfowl/Micronetes/commit/5c960b4a556e0a490d5094e9fe2edfa27c8446c9