Method: Docker::Compose::Session#port
- Defined in:
- lib/docker/compose/session.rb
permalink #port(service, port, protocol: 'tcp', index: 1) ⇒ String?
Figure out which interface(s) and port a given service port has been published to.
NOTE: if Docker Compose is communicating with a remote Docker host, this method returns IP addresses from the point of view of that host and its interfaces. If you need to know the address as reachable from localhost, you probably want to use ‘Mapper`.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/docker/compose/session.rb', line 201 def port(service, port, protocol: 'tcp', index: 1) inter = @shell.interactive @shell.interactive = false o = opts(protocol: [protocol, 'tcp'], index: [index, 1]) s = strip_ansi(run!('port', o, service, port).strip) (!s.empty? && s) || nil rescue Error => e # Deal with docker-compose v1.11+ if e.detail =~ /No container found/i nil else raise end ensure @shell.interactive = inter end |