本文整理汇总了Java中com.github.dockerjava.core.command.PullImageResultCallback类的典型用法代码示例。如果您正苦于以下问题:Java PullImageResultCallback类的具体用法?Java PullImageResultCallback怎么用?Java PullImageResultCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PullImageResultCallback类属于com.github.dockerjava.core.command包,在下文中一共展示了PullImageResultCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: pullImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
/**
* pulls {@link Image} from {@link Registry}
*
* @param imageName - imageName of {@link Element}
* @throws Exception
*/
public void pullImage(String imageName) throws Exception {
String tag = null;
String registry = imageName;
if (registry.contains(":")) {
String[] sp = registry.split(":");
registry = sp[0];
tag = sp[1];
}
PullImageCmd req = dockerClient.pullImageCmd(registry).withAuthConfig(dockerClient.authConfig());
if (tag != null)
req.withTag(tag);
PullImageResultCallback res = new PullImageResultCallback();
res = req.exec(res);
res.awaitSuccess();
}
开发者ID:iotracks,项目名称:iofabric,代码行数:22,代码来源:DockerUtil.java
示例2: call
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public Void call() throws Exception {
final ConsoleLogger console = new ConsoleLogger(listener);
DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, authConfig);
PullImageCmd pullImageCmd = client.pullImageCmd(fromImageRes);
PullImageResultCallback callback = new PullImageResultCallback() {
@Override
public void onNext(PullResponseItem item) {
console.logInfo(item.toString());
super.onNext(item);
}
@Override
public void onError(Throwable throwable) {
console.logError("Failed to exec start:" + throwable.getMessage());
super.onError(throwable);
}
};
pullImageCmd.exec(callback).awaitSuccess();
return null;
}
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:23,代码来源:PullImageRemoteCallable.java
示例3: pullImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pullImage(String imageName) {
this.readWriteLock.readLock().lock();
try {
final Image image = Image.valueOf(imageName);
PullImageCmd pullImageCmd = this.dockerClient.pullImageCmd(image.getName());
String tag = image.getTag();
if (tag != null && !"".equals(tag)) {
pullImageCmd.withTag(tag);
} else {
pullImageCmd.withTag("latest");
}
pullImageCmd.exec(new PullImageResultCallback()).awaitSuccess();
} finally {
this.readWriteLock.readLock().unlock();
}
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:22,代码来源:DockerClientExecutor.java
示例4: loadImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private void loadImage ( String imageName )
throws InterruptedException {
MyHandler handler = new MyHandler();
// AuthConfig authConfig = new AuthConfig()
// .withUsername( "peterdnight" )
// .withPassword( "pet6er82" )
// .withEmail( "[email protected]" )
// .withRegistryAddress( registryName );
// authConfig.wi
PullImageResultCallback cb = dockerClient
.pullImageCmd( imageName )
.withTag( "latest" )
// .withAuthConfig( authConfig )
.exec( handler ).awaitCompletion();
}
开发者ID:csap-platform,项目名称:csap-core,代码行数:18,代码来源:Docker_Java.java
示例5: pullImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private static String pullImage(String registryHost, String imageName, String tag) {
checkArgument(!Strings.isNullOrEmpty(registryHost));
checkArgument(!Strings.isNullOrEmpty(imageName));
String tag1 = Strings.isNullOrEmpty(tag) ? "latest" : tag;
String fullQualifiedImageName = String.format("%s/%s:%s", registryHost, imageName, tag1);
dockerClient
.pullImageCmd(fullQualifiedImageName)
.exec(new PullImageResultCallback())
.awaitSuccess();
String fullQualifiedImageId =
dockerClient.inspectImageCmd(fullQualifiedImageName).exec().getId();
fullQualifiedImageId = fullQualifiedImageId.substring(fullQualifiedImageId.indexOf(":") + 1);
return fullQualifiedImageId.substring(0, IMAGE_ID_LENGTH);
}
开发者ID:scalecube,项目名称:docker-utils,代码行数:17,代码来源:Containers.java
示例6: init
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public static void init() {
DefaultDockerClientConfig conf = DefaultDockerClientConfig
.createDefaultConfigBuilder()
.withRegistryUrl("https://index.docker.io/v1/").build();
dockerClient =
DockerClientBuilder.getInstance(conf).withDockerCmdExecFactory(new NettyDockerCmdExecFactory()).build();
try {
dockerClient.inspectImageCmd("busybox").exec();
} catch (Exception e) {
LOGGER.info("Pulling image 'busybox'");
// need to block until image is pulled completely
dockerClient.pullImageCmd("busybox").withTag("latest").exec(new PullImageResultCallback()).awaitSuccess();
}
String logRecord = "This is magic string keyToFind=42 and some text at the end";
container = dockerClient.createContainerCmd("busybox")
.withCmd("/bin/sh", "-c", "while true; do echo " + logRecord + "; sleep 1; done")
.withTty(true)
.exec();
dockerClient.startContainerCmd(container.getId()).exec();
}
开发者ID:scalecube,项目名称:docker-utils,代码行数:24,代码来源:LogParsingTest.java
示例7: ensureImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public static void ensureImage(String imageName) {
List<Image> images = dockerClient.listImagesCmd().withImageNameFilter(imageName).exec();
if (images.isEmpty()){
logger.info("Pulling docker image from Docker Hub ...");
// FIXME: Figure out how image tags should work
dockerClient.pullImageCmd(imageName).withTag("latest")
.exec(new PullImageResultCallback(){
@Override
public void onNext(PullResponseItem item) {
super.onNext(item);
logger.debug(item.toString());
}
})
.awaitSuccess();
logger.info("Finished pulling docker image.");
}
}
开发者ID:b-long,项目名称:jedi,代码行数:18,代码来源:ContainerUtils.java
示例8: pull
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pull(InstanceStartRequest request, InstanceStartResponse response) {
try {
dockerClient.pullImageCmd(request.getRepository()).exec(new PullImageResultCallback() {
@Override
public void onNext(PullResponseItem item) {
super.onNext(item);
if (logger.isDebugEnabled()) {
logger.debug(item);
}
}
}).awaitSuccess();
response.success();
} catch (Exception e) {
response.fail(e.toString());
logger.error(String.format("error pullImage: %s", request), e);
}
}
开发者ID:dianping,项目名称:Dolphin,代码行数:18,代码来源:DockerImageServiceImpl.java
示例9: before
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
// LOG.info("======================= BEFORETEST =======================");
LOG.debug("Connecting to Docker server");
try {
getClient().inspectImageCmd(DEFAULT_IMAGE).exec();
} catch (NotFoundException e) {
LOG.info("Pulling image 'busybox'");
// need to block until image is pulled completely
getClient().pullImageCmd("busybox")
.withTag("latest")
.exec(new PullImageResultCallback())
.awaitSuccess();
}
// assertThat(getClient(), notNullValue());
// LOG.info("======================= END OF BEFORETEST =======================\n\n");
}
开发者ID:docker-java,项目名称:docker-java,代码行数:21,代码来源:DockerRule.java
示例10: generateEvents
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
/**
* This method generates some events and returns the number of events being generated
*/
private int generateEvents() throws Exception {
String testImage = "busybox:latest";
dockerRule.getClient().pullImageCmd(testImage).exec(new PullImageResultCallback()).awaitSuccess();
CreateContainerResponse container = dockerRule.getClient().createContainerCmd(testImage).withCmd("sleep", "9999").exec();
dockerRule.getClient().startContainerCmd(container.getId()).exec();
dockerRule.getClient().stopContainerCmd(container.getId()).withTimeout(1).exec();
// generates 5 events with remote api 1.24:
// Event[status=pull,id=busybox:latest,from=<null>,node=<null>,type=IMAGE,action=pull,[email protected][id=busybox:latest,attributes={name=busybox}],time=1473455186,timeNano=1473455186436681587]
// Event[status=create,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=create,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport}],time=1473455186,timeNano=1473455186470713257]
// Event[status=<null>,id=<null>,from=<null>,node=<null>,type=NETWORK,action=connect,[email protected][id=10870ceb13abb7cf841ea68868472da881b33c8ed08d2cde7dbb39d7c24d1d27,attributes={container=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c, name=bridge, type=bridge}],time=1473455186,timeNano=1473455186544318466]
// Event[status=start,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=start,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport}],time=1473455186,timeNano=1473455186786163819]
// Event[status=kill,id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,from=busybox:latest,node=<null>,type=CONTAINER,action=kill,[email protected][id=6ec10182cde227040bfead8547b63105e6bbc4e94b99f6098bfad6e158ce0d3c,attributes={image=busybox:latest, name=sick_lamport, signal=15}],time=1473455186,timeNano=1473455186792963392]
return 5;
}
开发者ID:docker-java,项目名称:docker-java,代码行数:22,代码来源:EventsCmdIT.java
示例11: testPullImageWithNoAuth
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Test
public void testPullImageWithNoAuth() throws Exception {
RegistryUtils.runPrivateRegistry(dockerRule.getClient());
String imgName = RegistryUtils.createPrivateImage(dockerRule, "pull-image-with-no-auth");
if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient())
.isGreaterOrEqual(RemoteApiVersion.VERSION_1_30)) {
exception.expect(InternalServerErrorException.class);
} else {
exception.expect(DockerClientException.class);
}
// stream needs to be fully read in order to close the underlying connection
dockerRule.getClient().pullImageCmd(imgName)
.exec(new PullImageResultCallback())
.awaitCompletion(30, TimeUnit.SECONDS);
}
开发者ID:docker-java,项目名称:docker-java,代码行数:19,代码来源:PullImageCmdIT.java
示例12: testPullImageWithInvalidAuth
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Test
public void testPullImageWithInvalidAuth() throws Exception {
AuthConfig validAuthConfig = RegistryUtils.runPrivateRegistry(dockerRule.getClient());
AuthConfig authConfig = new AuthConfig()
.withUsername("testuser")
.withPassword("testwrongpassword")
.withEmail("[email protected]")
.withRegistryAddress(validAuthConfig.getRegistryAddress());
String imgName = RegistryUtils.createPrivateImage(dockerRule, "pull-image-with-invalid-auth");
if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient())
.isGreaterOrEqual(RemoteApiVersion.VERSION_1_30)) {
exception.expect(InternalServerErrorException.class);
} else {
exception.expect(DockerClientException.class);
}
// stream needs to be fully read in order to close the underlying connection
dockerRule.getClient().pullImageCmd(imgName)
.withAuthConfig(authConfig)
.exec(new PullImageResultCallback())
.awaitCompletion(30, TimeUnit.SECONDS);
}
开发者ID:docker-java,项目名称:docker-java,代码行数:26,代码来源:PullImageCmdIT.java
示例13: pullImage
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
void pullImage(DockerAPI api, TaskListener listener) throws IOException, InterruptedException {
String image = getFullImageId();
final DockerClient client = api.getClient();
if (pullStrategy.shouldPullImage(client, image)) {
// TODO create a FlyWeightTask so end-user get visibility on pull operation progress
LOGGER.info("Pulling image '{}'. This may take awhile...", image);
long startTime = System.currentTimeMillis();
PullImageCmd cmd = client.pullImageCmd(image);
final DockerRegistryEndpoint registry = getRegistry();
DockerCloud.setRegistryAuthentication(cmd, registry, Jenkins.getInstance());
cmd.exec(new PullImageResultCallback() {
@Override
public void onNext(PullResponseItem item) {
listener.getLogger().println(item.getStatus());
}
}).awaitCompletion();
try {
client.inspectImageCmd(image).exec();
} catch (NotFoundException e) {
throw new DockerClientException("Could not pull image: " + image, e);
}
long pullTime = System.currentTimeMillis() - startTime;
LOGGER.info("Finished pulling image '{}', took {} ms", image, pullTime);
}
}
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:33,代码来源:DockerTemplate.java
示例14: createContainer
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private CreateContainerResponse createContainer(@NonNull final DockerClient _dockerClient,
@NonNull final String _dispatcher) {
synchronized(this) {
if (_dockerClient.listImagesCmd().withImageNameFilter(_dispatcher).exec().isEmpty()) {
log.info("Image '" + _dispatcher + "' not found. Please wait while pulling from main repository...");
boolean success = false;
try {
success = _dockerClient.pullImageCmd(_dispatcher)
.exec(new PullImageResultCallback() {
@Override
public void onNext(PullResponseItem item) {
//System.out.println("" + item);
super.onNext(item);
}
})
.awaitCompletion(5, TimeUnit.MINUTES);
} catch (InterruptedException _e) {
// ignore
}
if (!success) {
throw new RuntimeException("Unable to retrieve image:" + _dispatcher);
}
} else {
log.debug("Image found.");
}
}
return _dockerClient
.createContainerCmd(_dispatcher)
.withEntrypoint("/bin/sh")
.withTty(true)
.exec();
}
开发者ID:jonfryd,项目名称:tifoon,代码行数:37,代码来源:DockerExecutorPlugin.java
示例15: pullImageIfNecessary
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void pullImageIfNecessary(String imageId) {
if (!existsImage(imageId)) {
log.info("Pulling Docker image {} ... please wait", imageId);
dockerClient.pullImageCmd(imageId)
.exec(new PullImageResultCallback()).awaitSuccess();
log.trace("Docker image {} downloaded", imageId);
}
}
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:9,代码来源:DockerService.java
示例16: ensureImageExists
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
private void ensureImageExists(String wantedImage) {
try {
dockerClient.inspectImageCmd(wantedImage).exec();
} catch (NotFoundException e) {
dockerClient.pullImageCmd(wantedImage).exec(new PullImageResultCallback()).awaitSuccess();
}
}
开发者ID:FaustXVI,项目名称:junit5-docker,代码行数:8,代码来源:DefaultDockerClient.java
示例17: initTestContainer
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
protected void initTestContainer()
throws Exception {
final String scenarioFileName = scenarioPath.getFileName().toString();
int dotPos = scenarioFileName.lastIndexOf('.');
if(dotPos > 0) {
final String scenarioFileExt = scenarioFileName.substring(dotPos + 1);
final String dockerImageName = SCENARIO_LANG_IMAGES.get(scenarioFileExt);
if(dockerImageName == null) {
fail();
}
System.out.println("docker pull " + dockerImageName + "...");
dockerClient.pullImageCmd(dockerImageName)
.exec(new PullImageResultCallback())
.awaitSuccess();
final List<String> cmd = new ArrayList<>();
cmd.add("-Xms1g");
cmd.add("-Xmx1g");
cmd.add("-XX:MaxDirectMemorySize=1g");
cmd.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
cmd.add("-Dcom.sun.management.jmxremote=true");
cmd.add("-Dcom.sun.management.jmxremote.port=9010");
cmd.add("-Dcom.sun.management.jmxremote.rmi.port=9010");
cmd.add("-Dcom.sun.management.jmxremote.local.only=false");
cmd.add("-Dcom.sun.management.jmxremote.authenticate=false");
cmd.add("-Dcom.sun.management.jmxremote.ssl=false");
cmd.add("-jar");
cmd.add("/opt/mongoose/mongoose.jar");
cmd.addAll(configArgs);
final StringJoiner cmdLine = new StringJoiner(" ");
cmd.forEach(cmdLine::add);
System.out.println("Container arguments: " + cmdLine.toString());
final Volume volumeShare = new Volume(CONTAINER_SHARE_PATH);
final Volume volumeLog = new Volume(CONTAINER_LOG_PATH);
final Bind[] binds = new Bind[] {
new Bind(HOST_SHARE_PATH.toString(), volumeShare),
new Bind(HOST_LOG_PATH.toString(), volumeLog),
};
// put the environment variables into the container
final Map<String, String> envMap = System.getenv();
final String[] env = envMap.keySet().toArray(new String[envMap.size()]);
for(int i = 0; i < env.length; i ++) {
if("PATH".equals(env[i])) {
env[i] = env[i] + "=" + envMap.get(env[i]) + ":/bin";
} else {
env[i] = env[i] + "=" + envMap.get(env[i]);
}
}
final CreateContainerResponse container = dockerClient
.createContainerCmd(dockerImageName)
.withName("mongoose")
.withNetworkMode("host")
.withExposedPorts(ExposedPort.tcp(9010), ExposedPort.tcp(5005))
.withVolumes(volumeShare, volumeLog)
.withBinds(binds)
.withAttachStdout(true)
.withAttachStderr(true)
.withEnv(env)
.withEntrypoint("mongoose")
.withCmd(cmd)
.exec();
testContainerId = container.getId();
dockerClient
.attachContainerCmd(testContainerId)
.withStdErr(true)
.withStdOut(true)
.withFollowStream(true)
.exec(streamsCallback);
} else {
fail();
}
}
开发者ID:emc-mongoose,项目名称:mongoose-base,代码行数:80,代码来源:ScenarioTestBase.java
示例18: init
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
public void init() {
if (dc == null) {
DockerClientConfig.DockerClientConfigBuilder builder = DockerClientConfig.createDefaultConfigBuilder();
DockerClientConfig config = builder.build();
dc = DockerClientBuilder.getInstance(config).build();
dc.pullImageCmd(imageName).withTag(imageVersion).exec(new PullImageResultCallback()).awaitSuccess();
}
if (dockerPool == null) {
dockerPool = Executors.newFixedThreadPool(poolSize);
}
}
开发者ID:microservices-demo,项目名称:queue-master,代码行数:14,代码来源:DockerSpawner.java
示例19: run
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Override
protected Void run() throws Exception {
LOG.debug("Pulling image: [{}]", imageName);
PullImageResultCallback callBack = new PullImageResultCallback();
Sssh.waitForCompletion(dockerClient.pullImageCmd(imageName).exec(callBack));
LOG.debug("Pulled image: [{}]", imageName);
return null;
}
开发者ID:Qorr,项目名称:Hvalspik,代码行数:10,代码来源:PullImageCommand.java
示例20: run
import com.github.dockerjava.core.command.PullImageResultCallback; //导入依赖的package包/类
@Override
public List<String> run(TestEnvironment testEnvironment) {
String hostOsMountDir = System.getProperties().getProperty("buildDirectory");
CreateContainerCmd containerBuilder = dockerClient.createContainerCmd(testEnvironment.getImage())
.withBinds(new Bind(hostOsMountDir, new Volume(Constants.HAWKULAR_APM_AGENT_DIRECTORY),
AccessMode.ro, SELContext.shared),
new Bind(scenarioDirectory, new Volume(Constants.HAWKULAR_APM_TEST_DIRECTORY),
AccessMode.ro, SELContext.shared))
.withExtraHosts(Constants.HOST_ADDED_TO_ETC_HOSTS + ":" + apmBindAddress);
if (userDefinedNetwork) {
if (network == null) {
throw new IllegalStateException("Create network before running environment");
}
containerBuilder.withNetworkMode(network.getName());
}
containerBuilder.withEnv(apmEnvVariables(testEnvironment.getType()));
if (testEnvironment.isPull()) {
log.info("Pulling image...");
dockerClient.pullImageCmd(testEnvironment.getImage()).exec(new PullImageResultCallback()).awaitSuccess();
}
CreateContainerResponse containerResponse = containerBuilder.exec();
log.info(String.format("Starting docker container: %s", containerResponse));
try {
dockerClient.startContainerCmd(containerResponse.getId()).exec();
} catch (DockerException ex) {
log.severe(String.format("Could not create or start docker container: %s", containerResponse));
throw new EnvironmentException("Could not create or start docker container.", ex);
}
return Arrays.asList(containerResponse.getId());
}
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:39,代码来源:DockerImageExecutor.java
注:本文中的com.github.dockerjava.core.command.PullImageResultCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论