com.github.dockerjava.api.model
Class Ports.Binding

java.lang.Object
  extended by com.github.dockerjava.api.model.Ports.Binding
Enclosing class:
Ports

public static class Ports.Binding
extends Object

A Ports.Binding represents a socket on the Docker host that is used in a PortBinding. It is characterized by an IP address and a port number. Both properties may be null in order to let Docker assign them dynamically/using defaults.

See Also:
Ports.bind(ExposedPort, Binding), ExposedPort

Constructor Summary
Ports.Binding()
          Creates a Ports.Binding with both IP address and port number undefined.
Ports.Binding(Integer hostPort)
          Creates a Ports.Binding for the given port number, leaving the IP address undefined.
Ports.Binding(String hostIp)
          Creates a Ports.Binding for the given IP address, leaving the port number undefined.
Ports.Binding(String hostIp, Integer hostPort)
          Creates a Ports.Binding for the given IP address and port number.
 
Method Summary
 boolean equals(Object obj)
           
 String getHostIp()
           
 Integer getHostPort()
           
static Ports.Binding parse(String serialized)
          Parses a textual host and port specification (as used by the Docker CLI) to a Ports.Binding.
 String toString()
          Returns a string representation of this Ports.Binding suitable for inclusion in a JSON message.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ports.Binding

public Ports.Binding(String hostIp,
                     Integer hostPort)
Creates a Ports.Binding for the given IP address and port number.

See Also:
Ports.bind(ExposedPort, Binding), ExposedPort

Ports.Binding

public Ports.Binding(Integer hostPort)
Creates a Ports.Binding for the given port number, leaving the IP address undefined.

See Also:
Ports.bind(ExposedPort, Binding), ExposedPort

Ports.Binding

public Ports.Binding(String hostIp)
Creates a Ports.Binding for the given IP address, leaving the port number undefined.


Ports.Binding

public Ports.Binding()
Creates a Ports.Binding with both IP address and port number undefined.

Method Detail

getHostIp

public String getHostIp()
Returns:
the IP address on the Docker host. May be null, in which case Docker will bind the port to all interfaces (0.0.0.0).

getHostPort

public Integer getHostPort()
Returns:
the port number on the Docker host. May be null, in which case Docker will dynamically assign a port.

parse

public static Ports.Binding parse(String serialized)
                           throws IllegalArgumentException
Parses a textual host and port specification (as used by the Docker CLI) to a Ports.Binding.

Legal syntax: IP|IP:port|port

Parameters:
serialized - serialized the specification, e.g. 127.0.0.1:80
Returns:
a Ports.Binding matching the specification
Throws:
IllegalArgumentException - if the specification cannot be parsed

toString

public String toString()
Returns a string representation of this Ports.Binding suitable for inclusion in a JSON message. The format is [IP:]Port, like the argument in parse(String).

Overrides:
toString in class Object
Returns:
a string representation of this Ports.Binding

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2014. All rights reserved.