String image = config.getFabricDockerImage();
String containerName = "fabric1";
//String dockerHost = dockerFactory.getDockerHost();
String dockerHost = "localhost";
ContainerConfig containerConfig = new ContainerConfig();
containerConfig.setImage(image);
containerConfig.setAttachStdout(true);
containerConfig.setAttachStderr(true);
containerConfig.setTty(true);
containerConfig.setEntrypoint(null);
Map<String, Object> exposedPorts = new HashMap<>();
Map<String, String> emptyMap = new HashMap<>();
int[] rootContainerExposedPorts = config.getRootContainerExposedPorts();
for (int exposedPort : rootContainerExposedPorts) {
String portText = "" + exposedPort + "/tcp";
exposedPorts.put(portText, emptyMap);
}
containerConfig.setExposedPorts(exposedPorts);
System.out.println("Exposing ports: " + exposedPorts);
Map<String, String> envVars = createChildEnvironmentVariables();
envVars.put(EnvironmentVariables.FABRIC8_GLOBAL_RESOLVER, "manualip");
envVars.put(EnvironmentVariables.FABRIC8_MANUALIP, dockerHost);
envVars.put(EnvironmentVariables.RUNTIME_ID, containerName);
envVars.put(EnvironmentVariables.KARAF_NAME, containerName);
List<String> envList = Dockers.toEnvList(envVars);
containerConfig.setEnv(envList);
System.out.println("Creating docker container name " + containerName
+ " with config: " + containerConfig);
ContainerCreateStatus status = docker.containerCreate(containerConfig, containerName);
rootDockerContainerId = status.getId();
String[] warnings = status.getWarnings();