containerConfigBuilder.volumes(volumes);
}
Config containerConfig = containerConfigBuilder.build();
logger.debug(">> creating new container with containerConfig(%s)", containerConfig);
Container container = api.getRemoteApi().createContainer(name, containerConfig);
logger.trace("<< container(%s)", container.getId());
HostConfig.Builder hostConfigBuilder = HostConfig.builder()
.publishAllPorts(true)
.privileged(true);
if (templateOptions.getDns().isPresent()) {
hostConfigBuilder.dns(templateOptions.getDns().get());
}
// set up for volume bindings
if (templateOptions.getVolumes().isPresent()) {
for (Map.Entry<String, String> entry : templateOptions.getVolumes().get().entrySet()) {
hostConfigBuilder.binds(ImmutableList.of(entry.getKey() + ":" + entry.getValue()));
}
}
HostConfig hostConfig = hostConfigBuilder.build();
api.getRemoteApi().startContainer(container.getId(), hostConfig);
container = api.getRemoteApi().inspectContainer(container.getId());
if (container.getState().getExitCode() != 0) {
destroyNode(container.getId());
throw new IllegalStateException(String.format("Container %s has not started correctly", container.getId()));
}
return new NodeAndInitialCredentials<Container>(container, container.getId(),
LoginCredentials.builder().user(loginUser).password(loginUserPassword).build());
}