Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2016-03-11 21:36:09 +0000
committerRoland Grunberg2016-03-17 20:30:29 +0000
commitc29ae1424cba884d0eb18ce67ae77db67432d9b5 (patch)
treee113f2eb11a1f728a827e942386c5164f2301411
parentf068b2ec23dfbc73391d30954fc1e0f9b1ee4c71 (diff)
downloadorg.eclipse.linuxtools-c29ae1424cba884d0eb18ce67ae77db67432d9b5.tar.gz
org.eclipse.linuxtools-c29ae1424cba884d0eb18ce67ae77db67432d9b5.tar.xz
org.eclipse.linuxtools-c29ae1424cba884d0eb18ce67ae77db67432d9b5.zip
Make sure to expose ports in the 'ExposedPorts' parameter.
In order to publish a container's ports to the host one must pass the exposed container ports to the DockerContainerConfig (ExposedPorts) in addition to defining the port bindings in the DockerHostConfig (PortBindings). Change-Id: I4bb2510ee580b55b0a839c738a10a8e8c678b6e1 Reviewed-on: https://git.eclipse.org/r/68257 Tested-by: Hudson CI Reviewed-by: Roland Grunberg <rgrunber@redhat.com> Reviewed-on: https://git.eclipse.org/r/68704
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
index 6e0263abc9..3e71411f5a 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRun.java
@@ -16,9 +16,11 @@ import static org.eclipse.linuxtools.internal.docker.ui.launch.IRunDockerImageLa
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -248,6 +250,21 @@ public class ImageRun extends Wizard {
environmentVariables.add(var.getName() + "=" + var.getValue()); //$NON-NLS-1$
}
config.env(environmentVariables);
+
+ if (!selectionModel.isPublishAllPorts()) {
+ final Set<String> exposedPorts = new HashSet<>();
+ for (Iterator<ExposedPortModel> iterator = selectionModel
+ .getExposedPorts().iterator(); iterator.hasNext();) {
+ final ExposedPortModel exposedPort = iterator.next();
+ // only selected Ports in the CheckboxTableViewer are exposed.
+ if (!selectionModel.getSelectedPorts().contains(exposedPort)) {
+ continue;
+ }
+ exposedPorts.add(exposedPort.getContainerPort()
+ + exposedPort.getPortType());
+ }
+ config.exposedPorts(exposedPorts);
+ }
return config.build();
}

Back to the top