diff options
author | freva <valerijf@yahoo-inc.com> | 2016-12-08 15:50:23 +0100 |
---|---|---|
committer | freva <valerijf@yahoo-inc.com> | 2016-12-08 15:50:23 +0100 |
commit | c2e83dc178aeec9be5121d6a118ee13a48e980d5 (patch) | |
tree | 5e54b139cee2a6ee90a5e614c456673a572bf3c0 /docker-api | |
parent | 7f2ad2c13962eaa8fd6752f6b3b445fb310fe3af (diff) |
Do not set MAC address if network mode is host
Diffstat (limited to 'docker-api')
-rw-r--r-- | docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImpl.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImpl.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImpl.java index 9e6f5121505..27b2a6b1d77 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImpl.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImpl.java @@ -134,11 +134,10 @@ class CreateContainerCommandImpl implements Docker.CreateContainerCommand { private CreateContainerCmd createCreateContainerCmd() { List<Bind> volumeBinds = volumeBindSpecs.stream().map(Bind::parse).collect(Collectors.toList()); - CreateContainerCmd containerCmd = docker + final CreateContainerCmd containerCmd = docker .createContainerCmd(dockerImage.asString()) .withName(containerName.asString()) .withHostName(hostName) - .withMacAddress(generateRandomMACAddress()) .withLabels(labels) .withEnv(environmentAssignments) .withBinds(volumeBinds) @@ -146,11 +145,15 @@ class CreateContainerCommandImpl implements Docker.CreateContainerCommand { .withCapAdd(new ArrayList<>(addCapabilities)) .withCapDrop(new ArrayList<>(dropCapabilities)); - if (memoryInB.isPresent()) containerCmd = containerCmd.withMemory(memoryInB.get()); - if (networkMode.isPresent()) containerCmd = containerCmd.withNetworkMode(networkMode.get()); - if (ipv4Address.isPresent()) containerCmd = containerCmd.withIpv4Address(ipv4Address.get()); - if (ipv6Address.isPresent()) containerCmd = containerCmd.withIpv6Address(ipv6Address.get()); - if (entrypoint.isPresent()) containerCmd = containerCmd.withEntrypoint(entrypoint.get()); + networkMode + .filter(mode -> ! mode.toLowerCase().equals("host")) + .ifPresent(mode -> containerCmd.withMacAddress(generateRandomMACAddress())); + + memoryInB.ifPresent(containerCmd::withMemory); + networkMode.ifPresent(containerCmd::withNetworkMode); + ipv4Address.ifPresent(containerCmd::withIpv4Address); + ipv6Address.ifPresent(containerCmd::withIpv6Address); + entrypoint.ifPresent(containerCmd::withEntrypoint); return containerCmd; } |