/** * Adds the specified {@link PortBinding}(s) to the list of {@link PortBinding}s. */ public void add(PortBinding... portBindings) { for (PortBinding binding : portBindings) { bind(binding.getExposedPort(), binding.getBinding()); } }
/** * {@inheritDoc} */ @Override public String getContainerId() { return this.container.getId(); } }
private static PortBinding createFromSubstrings(String binding, String exposedPort) throws IllegalArgumentException { return new PortBinding(Binding.parse(binding), ExposedPort.parse(exposedPort)); }
/** * Set any custom settings for the create command such as shared memory size. */ private HostConfig buildHostConfig() { HostConfig config = new HostConfig(); if (shmSize != null) { config.withShmSize(shmSize); } if (tmpFsMapping != null) { config.withTmpFs(tmpFsMapping); } return config; }
/** * Creates an {@link ExposedPort} for {@link InternetProtocol#TCP}. This is a shortcut for * <code>new ExposedPort(port, {@link InternetProtocol#TCP})</code> */ public static ExposedPort tcp(int port) { return new ExposedPort(port, TCP); }
/** * Creates a {@link Ports} object with an initial {@link PortBinding} for the specified {@link ExposedPort} and {@link Binding}. Use * {@link #bind(ExposedPort, Binding)} or {@link #add(PortBinding...)} to add more {@link PortBinding}s. */ public Ports(ExposedPort exposedPort, Binding host) { bind(exposedPort, host); }
/** * Creates a {@link Binding} for the given {@link #getHostIp() IP address}, leaving the {@link #getHostPortSpec() port spec} * undefined. */ public static Binding bindIp(String hostIp) { return new Binding(hostIp, null); }
@Override public void serialize(VolumesRW value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); for (final VolumeRW volumeRW : value.volumesRW) { jgen.writeBooleanField(volumeRW.getVolume().getPath(), volumeRW.getAccessMode().toBoolean()); } jgen.writeEndObject(); }
/** * @see #links */ public ContainerNetwork withLinks(Link... links) { this.links = new Links(links); return this; }
/** * Returns a string representation of this {@link VolumeRW} suitable for inclusion in a JSON message. The returned String is simply the * container path, {@link #getPath()}. * * @return a string representation of this {@link VolumeRW} */ @Override public String toString() { return getVolume() + ":" + getAccessMode(); }
@Override public Swarm withId(String id) { super.withId(id); return this; }
/** * Creates a {@link Binding} for the given port range, leaving the {@link #getHostIp() IP address} * undefined. */ public static Binding bindPortRange(int lowPort, int highPort) { return bindIpAndPortRange(null, lowPort, highPort); }
/** * Restart the container unless it has been stopped */ public static RestartPolicy unlessStoppedRestart() { return new RestartPolicy(0, "unless-stopped"); }
@Override public Swarm withSpec(SwarmSpec spec) { super.withSpec(spec); return this; }
/** * Returns a string representation of this {@link ExposedPort} suitable for inclusion in a JSON message. The format is * <code>port/protocol</code>, like the argument in {@link #parse(String)}. * * @return a string representation of this {@link ExposedPort} */ @Override public String toString() { return port + "/" + protocol.toString(); }
/** * Creates an {@link ExposedPort} for {@link InternetProtocol#UDP}. This is a shortcut for * <code>new ExposedPort(port, {@link InternetProtocol#UDP})</code> */ public static ExposedPort udp(int port) { return new ExposedPort(port, UDP); }
/** * Creates a {@link Binding} for the given {@link #getHostIp() IP address} and port range. */ public static Binding bindIpAndPortRange(String hostIp, int lowPort, int highPort) { return new Binding(hostIp, lowPort + "-" + highPort); }
/** * @see #links */ public ContainerNetwork withLinks(List<Link> links) { this.links = new Links(links); return this; }
/** * Creates a {@link Binding} for the given {@link #getHostPortSpec() port spec}, leaving the {@link #getHostIp() IP address} * undefined. * * @see Ports#bind(ExposedPort, Binding) * @see ExposedPort */ public static Binding bindPortSpec(String portSpec) { return new Binding(null, portSpec); }
/** * Creates a {@link Binding} for the given {@link #getHostIp() IP address} and port number. */ public static Binding bindIpAndPort(String hostIp, int port) { return new Binding(hostIp, "" + port); }