converge icon indicating copy to clipboard operation
converge copied to clipboard

Easily reference exposed ports in docker module

Open sehqlr opened this issue 8 years ago • 2 comments

This would add a "ports" field to lookup that would have an exposed port as a key, and the value would be the port assigned to it on the host. This would work the same whether the host port was manually or automatically assigned. The syntax would be something like this:

docker.container "nginx" {
  expose = ["80", "433"]
}

task "curl nginx container" {
  check = "curl {{lookup `docker.container.nginx.ports.80`}}"
  ...
}

sehqlr avatar Sep 14 '16 15:09 sehqlr

Just as a note, the recommended docker syntax for printing the host port of a container is this invocation of docker inspect:

docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID

source.

sehqlr avatar Sep 26 '16 15:09 sehqlr

to this effectively, we also need to be able to do a lookup on map fields.

ryane avatar Oct 25 '16 13:10 ryane