public static class Ports.Binding extends DockerObject implements Serializable
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 spec
. Both properties may be null
in order to
let Docker assign them dynamically/using defaults.Constructor and Description |
---|
Binding(String hostIp,
String hostPortSpec)
|
Modifier and Type | Method and Description |
---|---|
static Ports.Binding |
bindIp(String hostIp)
|
static Ports.Binding |
bindIpAndPort(String hostIp,
int port)
Creates a
Ports.Binding for the given IP address and port number. |
static Ports.Binding |
bindIpAndPortRange(String hostIp,
int lowPort,
int highPort)
Creates a
Ports.Binding for the given IP address and port range. |
static Ports.Binding |
bindPort(int port)
Creates a
Ports.Binding for the given port leaving the IP address
undefined. |
static Ports.Binding |
bindPortRange(int lowPort,
int highPort)
Creates a
Ports.Binding for the given port range, leaving the IP address
undefined. |
static Ports.Binding |
bindPortSpec(String portSpec)
|
static Ports.Binding |
empty()
Creates an empty
Ports.Binding . |
String |
getHostIp() |
String |
getHostPortSpec() |
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. |
getRawValues
public Binding(String hostIp, String hostPortSpec)
Ports.bind(ExposedPort, Binding)
,
ExposedPort
public static Ports.Binding bindPortSpec(String portSpec)
Ports.bind(ExposedPort, Binding)
,
ExposedPort
public static Ports.Binding bindIp(String hostIp)
public static Ports.Binding bindIpAndPort(String hostIp, int port)
Ports.Binding
for the given IP address
and port number.public static Ports.Binding bindIpAndPortRange(String hostIp, int lowPort, int highPort)
Ports.Binding
for the given IP address
and port range.public static Ports.Binding bindPortRange(int lowPort, int highPort)
Ports.Binding
for the given port range, leaving the IP address
undefined.public static Ports.Binding bindPort(int port)
Ports.Binding
for the given port leaving the IP address
undefined.public static Ports.Binding empty()
Ports.Binding
.public String getHostIp()
null
, in which case Docker will bind the port to all interfaces (
0.0.0.0
).public String getHostPortSpec()
null
, in which case Docker will dynamically assign a port.public static Ports.Binding parse(String serialized) throws IllegalArgumentException
Ports.Binding
.
Legal syntax: IP|IP:portSpec|portSpec
where portSpec
is either a single port or a port range
serialized
- serialized the specification, e.g. 127.0.0.1:80
Ports.Binding
matching the specificationIllegalArgumentException
- if the specification cannot be parsedpublic String toString()
Ports.Binding
suitable for inclusion in a JSON message. The format is
[IP:]Port
, like the argument in parse(String)
.toString
in class Object
Ports.Binding
Copyright © 2021. All rights reserved.