use of io.fabric8.maven.docker.access.ContainerNetworkingConfig in project docker-maven-plugin by fabric8io.
the class RunService method createContainerConfig.
// visible for testing
ContainerCreateConfig createContainerConfig(String imageName, RunImageConfiguration runConfig, PortMapping mappedPorts, GavLabel gavLabel, Properties mavenProps, File baseDir) throws DockerAccessException {
try {
ContainerCreateConfig config = new ContainerCreateConfig(imageName).hostname(runConfig.getHostname()).domainname(runConfig.getDomainname()).user(runConfig.getUser()).workingDir(runConfig.getWorkingDir()).entrypoint(runConfig.getEntrypoint()).exposedPorts(mappedPorts.getContainerPorts()).environment(runConfig.getEnvPropertyFile(), runConfig.getEnv(), mavenProps).labels(mergeLabels(runConfig.getLabels(), gavLabel)).command(runConfig.getCmd()).hostConfig(createContainerHostConfig(runConfig, mappedPorts, baseDir));
RunVolumeConfiguration volumeConfig = runConfig.getVolumeConfiguration();
if (volumeConfig != null) {
resolveRelativeVolumeBindings(baseDir, volumeConfig);
config.binds(volumeConfig.getBind());
}
NetworkConfig networkConfig = runConfig.getNetworkingConfig();
if (networkConfig.isCustomNetwork() && networkConfig.hasAliases()) {
ContainerNetworkingConfig networkingConfig = new ContainerNetworkingConfig().aliases(networkConfig);
config.networkingConfig(networkingConfig);
}
return config;
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(String.format("Failed to create contained configuration for [%s]", imageName), e);
}
}
Aggregations