com.github.dockerjava.api.model
Class Ports

java.lang.Object
  extended by com.github.dockerjava.api.model.Ports

public class Ports
extends Object

A container for port bindings, made available as a Map via its getBindings() method.

Note: This is an abstraction used for querying existing port bindings from a container configuration. It is not to be confused with the PortBinding abstraction used for adding new port bindings to a container.

See Also:
HostConfig.getPortBindings(), InspectContainerResponse.NetworkSettings.getPorts()

Nested Class Summary
static class Ports.Binding
          A Ports.Binding represents a socket on the Docker host that is used in a PortBinding.
static class Ports.Deserializer
           
static class Ports.Serializer
           
 
Constructor Summary
Ports()
          Creates a Ports object with no PortBindings.
Ports(ExposedPort exposedPort, Ports.Binding host)
          Creates a Ports object with an initial PortBinding for the specified ExposedPort and Ports.Binding.
 
Method Summary
 void add(PortBinding... portBindings)
          Adds the specified PortBinding(s) to the list of PortBindings.
 void bind(ExposedPort exposedPort, Ports.Binding binding)
          Adds a new PortBinding for the specified ExposedPort and Ports.Binding to the current bindings.
static Ports.Binding Binding(Integer hostPort)
          Creates a Ports.Binding for the given port number, leaving the IP address undefined.
static Ports.Binding Binding(String hostIp, Integer hostPort)
          Creates a Ports.Binding for the given IP address and port number.
 Map<ExposedPort,Ports.Binding[]> getBindings()
          Returns the port bindings in the format used by the Docker remote API, i.e. the Ports.Bindings grouped by ExposedPort.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ports

public Ports()
Creates a Ports object with no PortBindings. Use bind(ExposedPort, Binding) or add(PortBinding...) to add PortBindings.


Ports

public Ports(ExposedPort exposedPort,
             Ports.Binding host)
Creates a Ports object with an initial PortBinding for the specified ExposedPort and Ports.Binding. Use bind(ExposedPort, Binding) or add(PortBinding...) to add more PortBindings.

Method Detail

bind

public void bind(ExposedPort exposedPort,
                 Ports.Binding binding)
Adds a new PortBinding for the specified ExposedPort and Ports.Binding to the current bindings.


add

public void add(PortBinding... portBindings)
Adds the specified PortBinding(s) to the list of PortBindings.


toString

public String toString()
Overrides:
toString in class Object

getBindings

public Map<ExposedPort,Ports.Binding[]> getBindings()
Returns the port bindings in the format used by the Docker remote API, i.e. the Ports.Bindings grouped by ExposedPort.

Returns:
the port bindings as a Map that contains one or more Ports.Bindings per ExposedPort.

Binding

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


Binding

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



Copyright © 2014. All Rights Reserved.