@Override public CreateContainerCmd build(ServiceDescriptor sd, CreateContainerCmd cmd, PortBinding pb) { List<ExposedPort> ports = new ArrayList<>(Arrays.asList(cmd.getExposedPorts())); ExposedPort containerPort = pb.protocol() .equals(Protocol.TCP) ? ExposedPort.tcp(pb.exposedPort()) : ExposedPort.udp(pb.exposedPort()); ports.add(containerPort); Ports bindings = cmd.getPortBindings(); if (bindings == null) { bindings = new Ports(); } bindings.bind(containerPort, pb.hostIp() .isEmpty() ? Binding.bindPort(pb.hostPort()) : Binding.bindIpAndPort(pb.hostIp(), pb.hostPort())); return cmd.withExposedPorts(ports) .withPortBindings(bindings); }
/** * Creates a {@link Binding} for the given port leaving the {@link #getHostIp() IP address} * undefined. */ public static Binding bindPort(int port) { return bindIpAndPort(null, port); }
/** * Creates a {@link Binding} for the given port leaving the {@link #getHostIp() IP address} * undefined. */ public static Binding bindPort(int port) { return bindIpAndPort(null, port); }