public final Binding getPortBinding ( final String portName ) throws IllegalStateException , IllegalArgumentException { assertStarted ( ) ; final Map < String , List < PortBinding > > ports = info . networkSettings ( ) . ports ( ) ; final List < PortBinding > portBindings = ports . get ( portName ) ; if ( portBindings == null || portBindings . isEmpty ( ) ) { throw new IllegalArgumentException ( "Unknown port binding: " + portName ) ; } final PortBinding portBinding = portBindings . get ( 0 ) ; return ImmutableBinding . builder ( ) // . host ( portBinding . hostIp ( ) ) // . port ( Integer . parseInt ( portBinding . hostPort ( ) ) ) // . build ( ) ; }
Returns the host and port information for the given Docker port name .