Skip to content

Commit 28e7d0c

Browse files
committed
Merge pull request #227 from ashmckenzie/amckenzie/missing-protocol-fix
Missing protocol fix
2 parents 25208b3 + c716421 commit 28e7d0c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
NAME=registrator
22
VERSION=$(shell cat VERSION)
3+
DEV_RUN_OPTS ?= consul:
34

45
dev:
56
docker build -f Dockerfile.dev -t $(NAME):dev .
67
docker run --rm \
78
-v /var/run/docker.sock:/tmp/docker.sock \
8-
$(NAME):dev /bin/registrator consul:
9+
$(NAME):dev /bin/registrator $(DEV_RUN_OPTS)
910

1011
build:
1112
mkdir -p build

bridge/util.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,27 @@ func serviceMetaData(config *dockerapi.Config, port string) map[string]string {
5656
}
5757

5858
func servicePort(container *dockerapi.Container, port dockerapi.Port, published []dockerapi.PortBinding) ServicePort {
59-
var hp, hip string
59+
var hp, hip, ep, ept string
6060
if len(published) > 0 {
6161
hp = published[0].HostPort
6262
hip = published[0].HostIP
6363
}
6464
if hip == "" {
6565
hip = "0.0.0.0"
6666
}
67-
p := strings.Split(string(port), "/")
67+
exposedPort := strings.Split(string(port), "/")
68+
ep = exposedPort[0]
69+
if len(exposedPort) == 2 {
70+
ept = exposedPort[1]
71+
} else {
72+
ept = "tcp" // default
73+
}
6874
return ServicePort{
6975
HostPort: hp,
7076
HostIP: hip,
71-
ExposedPort: p[0],
77+
ExposedPort: ep,
7278
ExposedIP: container.NetworkSettings.IPAddress,
73-
PortType: p[1],
79+
PortType: ept,
7480
ContainerID: container.ID,
7581
ContainerHostname: container.Config.Hostname,
7682
container: container,

0 commit comments

Comments
 (0)