Skip to content

Commit 3964c9e

Browse files
committed
Always expose container address
Previously, it was not possible to determine the IP address of a container without any EXPOSEd ports.
1 parent 8b99177 commit 3964c9e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

docker-gen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Address struct {
4747
Port string
4848
HostPort string
4949
Proto string
50+
HostIP string
5051
}
5152

5253
type Volume struct {
@@ -65,6 +66,7 @@ type RuntimeContainer struct {
6566
Volumes map[string]Volume
6667
Node SwarmNode
6768
Labels map[string]string
69+
IP string
6870
}
6971

7072
type DockerImage struct {

docker_client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func getContainers(client *docker.Client) ([]*RuntimeContainer, error) {
127127
Volumes: make(map[string]Volume),
128128
Node: SwarmNode{},
129129
Labels: make(map[string]string),
130+
IP: container.NetworkSettings.IPAddress,
130131
}
131132
for k, v := range container.NetworkSettings.Ports {
132133
address := Address{
@@ -136,6 +137,7 @@ func getContainers(client *docker.Client) ([]*RuntimeContainer, error) {
136137
}
137138
if len(v) > 0 {
138139
address.HostPort = v[0].HostPort
140+
address.HostIP = v[0].HostIP
139141
}
140142
runtimeContainer.Addresses = append(runtimeContainer.Addresses,
141143
address)

0 commit comments

Comments
 (0)