本文整理汇总了Java中com.github.dockerjava.core.DefaultDockerClientConfig.createDefaultConfigBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultDockerClientConfig.createDefaultConfigBuilder方法的具体用法?Java DefaultDockerClientConfig.createDefaultConfigBuilder怎么用?Java DefaultDockerClientConfig.createDefaultConfigBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.dockerjava.core.DefaultDockerClientConfig
的用法示例。
在下文中一共展示了DefaultDockerClientConfig.createDefaultConfigBuilder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DockerClientExecutor
import com.github.dockerjava.core.DefaultDockerClientConfig; //导入方法依赖的package包/类
public DockerClientExecutor(CubeDockerConfiguration cubeConfiguration) {
final DefaultDockerClientConfig.Builder configBuilder = DefaultDockerClientConfig
.createDefaultConfigBuilder();
String dockerServerUri = cubeConfiguration.getDockerServerUri();
dockerUri = URI.create(dockerServerUri);
dockerServerIp = cubeConfiguration.getDockerServerIp();
configBuilder.withApiVersion(cubeConfiguration.getDockerServerVersion())
.withDockerHost(dockerUri.toString());
if (cubeConfiguration.getUsername() != null) {
configBuilder.withRegistryUsername(cubeConfiguration.getUsername());
}
if (cubeConfiguration.getPassword() != null) {
configBuilder.withRegistryPassword(cubeConfiguration.getPassword());
}
if (cubeConfiguration.getEmail() != null) {
configBuilder.withRegistryEmail(cubeConfiguration.getEmail());
}
if (cubeConfiguration.getDockerRegistry() != null) {
configBuilder.withRegistryUrl(cubeConfiguration.getDockerRegistry());
}
if (cubeConfiguration.getCertPath() != null) {
configBuilder.withDockerCertPath(HomeResolverUtil.resolveHomeDirectoryChar(cubeConfiguration.getCertPath()));
}
configBuilder.withDockerTlsVerify(cubeConfiguration.getTlsVerify());
this.dockerClientConfig = configBuilder.build();
this.cubeConfiguration = cubeConfiguration;
this.dockerClient = buildDockerClient();
}
示例2: buildDockerClient
import com.github.dockerjava.core.DefaultDockerClientConfig; //导入方法依赖的package包/类
private static DockerClient buildDockerClient() {
Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder();
config.withDockerHost( "tcp://localhost:" + DockerTestUtils.DOCKER_TCP_PORT );
return DockerClientBuilder.getInstance( config.build()).build();
}
示例3: createRoboconfImage
import com.github.dockerjava.core.DefaultDockerClientConfig; //导入方法依赖的package包/类
@Test
@Ignore
public void createRoboconfImage() throws Exception {
// Verify no image exists
final String tag = "roboconf-test-by-hand";
Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder();
config.withDockerHost( "tcp://localhost:" + DockerTestUtils.DOCKER_TCP_PORT );
DockerClient docker = DockerClientBuilder.getInstance( config.build()).build();
Image img = DockerUtils.findImageByIdOrByTag( tag, docker );
if( img != null ) {
docker.removeImageCmd( tag ).exec();
img = DockerUtils.findImageByIdOrByTag( tag, docker );
}
Assert.assertNull( img );
// Prepare the parameters
File baseDir = new File( Thread.currentThread().getContextClassLoader().getResource( "./image/roboconf" ).getFile());
Assert.assertTrue( baseDir.exists());
Map<String,String> targetProperties = new HashMap<> ();
targetProperties.put( DockerHandler.IMAGE_ID, tag );
targetProperties.put( DockerHandler.GENERATE_IMAGE_FROM, "." );
TargetHandlerParameters parameters= new TargetHandlerParameters();
parameters.setTargetProperties( targetProperties );
parameters.setMessagingProperties( new HashMap<String,String>( 0 ));
parameters.setApplicationName( "applicationName" );
parameters.setScopedInstancePath( "/vm" );
parameters.setScopedInstance( new Instance());
parameters.setTargetPropertiesDirectory( baseDir );
File tmpFolder = this.folder.newFolder();
Map<String,File> containerIdToVolume = new HashMap<> ();
DockerMachineConfigurator configurator = new DockerMachineConfigurator(
parameters,
"machineId",
tmpFolder,
containerIdToVolume );
// Test the creation
Container container = null;
try {
configurator.configure();
img = DockerUtils.findImageByIdOrByTag( tag, docker );
Assert.assertNotNull( img );
String containerName = DockerUtils.buildContainerNameFrom(
parameters.getScopedInstancePath(),
parameters.getApplicationName());
container = DockerUtils.findContainerByIdOrByName( containerName, docker );
Assert.assertNotNull( container );
} finally {
if( img != null )
docker.removeImageCmd( tag ).exec();
img = DockerUtils.findImageByIdOrByTag( tag, docker );
Assert.assertNull( img );
if( container != null ) {
docker.removeContainerCmd( container.getId()).withForce( true ).exec();
container = DockerUtils.findContainerByIdOrByName( container.getId(), docker );
Assert.assertNull( container );
}
configurator.close();
}
}