Skip to content

Handling multiple ports for a docker container #2

@alexturek

Description

@alexturek

Hey Jason,

I think these two projects (docker-register and docker-discover) are filling a really useful niche for my company, and I'd like to add support for multiple TCP ports. I just wanted to walk through the fix to make sure it was a change you agreed with.

Since docker-discover already exposes a service with etcd keys like this:

/backends/<container name>/port = <port exposed by HAProxy>
/backends/<container name>/<container id> = <docker host:exposed docker port>

I was thinking we could just suffix with the port used by the process-in-the-container. E.g. if you have a docker ps like

CONTAINER ID   IMAGE           ....   PORTS                                             NAMES
xxxyyyzzz      some-web-process       0.0.0.0:49153->8000/tcp, 0.0.0.0:49154->9000/tcp  myservice

You could expose it in etcd with these keys:

/backends/myservice-8000/port = "80"
/backends/myservice-8000/xxxyyyzzz = "my.ip.he.re:49153"
/backends/myservice-9000/port = "5000"
/backends/myservice-9000/xxxyyyzzz = "my.ip.he.re:49154"

effectively treating a service with two ports like two separate services from the HAProxy perspective. This wouldn't require changing docker-discover at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions