本文整理汇总了Java中com.github.dockerjava.api.command.CreateVolumeResponse类的典型用法代码示例。如果您正苦于以下问题:Java CreateVolumeResponse类的具体用法?Java CreateVolumeResponse怎么用?Java CreateVolumeResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CreateVolumeResponse类属于com.github.dockerjava.api.command包,在下文中一共展示了CreateVolumeResponse类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCreate
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
private void doCreate(String name) {
CreateVolumeCmd createVolumeCmd = dockerClient.createVolumeCmd();
createVolumeCmd.withName(name);
driver = getPropertyAsString("volume_driver");
Map<String, String> driverOpts = (Map<String, String>) getProperty("volume_driver_opts");
if (StringUtils.isNotBlank(driver)) {
createVolumeCmd.withDriver(driver);
}
if (driverOpts != null && !driverOpts.isEmpty()) {
createVolumeCmd.withDriverOpts(driverOpts);
}
CreateVolumeResponse volumeResponse = createVolumeCmd.exec();
volumeId = volumeResponse.getName();
mountPoint = volumeResponse.getMountpoint();
driver = volumeResponse.getDriver();
log.info("Volume [{}]: Created new volume {} mounted at {} with driver {}", getId(), volumeId, mountPoint, driver);
initializeAttributes();
}
示例2: removeVolume
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Test(expected = NotFoundException.class)
public void removeVolume() throws DockerException {
String volumeName = "volume1" + dockerRule.getKind();
CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd()
.withName(volumeName)
.withDriver("local").exec();
assertThat(createVolumeResponse.getName(), equalTo(volumeName));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getMountpoint(), containsString(volumeName));
dockerRule.getClient().removeVolumeCmd(volumeName).exec();
dockerRule.getClient().inspectVolumeCmd(volumeName).exec();
}
示例3: createVolumeWithExistingName
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Test
public void createVolumeWithExistingName() throws DockerException {
String volumeName = "volume1";
CreateVolumeResponse createVolumeResponse1 = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
assertThat(createVolumeResponse1.getName(), equalTo(volumeName));
assertThat(createVolumeResponse1.getDriver(), equalTo("local"));
assertThat(createVolumeResponse1.getMountpoint(), containsString("/volume1/"));
CreateVolumeResponse createVolumeResponse2 = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
assertThat(createVolumeResponse2.getName(), equalTo(volumeName));
assertThat(createVolumeResponse2.getDriver(), equalTo("local"));
assertThat(createVolumeResponse2.getMountpoint(), equalTo(createVolumeResponse1.getMountpoint()));
}
示例4: execute
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Override
protected CreateVolumeResponse execute(CreateVolumeCmd command) {
WebTarget webResource = getBaseResource().path("/volumes/create");
LOGGER.trace("POST: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_JSON)
.post(entity(command, MediaType.APPLICATION_JSON), CreateVolumeResponse.class);
}
示例5: execute
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Override
protected CreateVolumeResponse execute(CreateVolumeCmd command) {
WebTarget webResource = getBaseResource().path("/volumes/create");
LOGGER.trace("POST: {}", webResource);
return webResource.request().accept(MediaType.APPLICATION_JSON)
.post(command, new TypeReference<CreateVolumeResponse>() {
});
}
示例6: listVolumes
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Test
public void listVolumes() throws DockerException {
CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName("volume1")
.withDriver("local").exec();
assertThat(createVolumeResponse.getName(), equalTo("volume1"));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/"));
ListVolumesResponse listVolumesResponse = dockerRule.getClient().listVolumesCmd().exec();
assertThat(listVolumesResponse.getVolumes().size(), greaterThanOrEqualTo(1));
}
示例7: createVolume
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Test
public void createVolume() throws DockerException {
String volumeName = "volume1";
CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
assertThat(createVolumeResponse.getName(), equalTo(volumeName));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/"));
}
示例8: createCreateVolumeCmdExec
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Override
public CreateVolumeCmd.Exec createCreateVolumeCmdExec() {
return new CreateVolumeCmd.Exec() {
@Override
public CreateVolumeResponse exec(CreateVolumeCmd command) {
CreateVolumeResponse result = delegate.createCreateVolumeCmdExec().exec(command);
volumeNames.add(command.getName());
return result;
}
};
}
示例9: createContainerWithVolumesFrom
import com.github.dockerjava.api.command.CreateVolumeResponse; //导入依赖的package包/类
@Test
public void createContainerWithVolumesFrom() throws DockerException {
String container1Name = UUID.randomUUID().toString();
CreateVolumeResponse volume1Info = dockerRule.getClient().createVolumeCmd().exec();
CreateVolumeResponse volume2Info = dockerRule.getClient().createVolumeCmd().exec();
Volume volume1 = new Volume("/src/webapp1");
Volume volume2 = new Volume("/src/webapp2");
Bind bind1 = new Bind(volume1Info.getName(), volume1);
Bind bind2 = new Bind(volume2Info.getName(), volume2);
// create a running container with bind mounts
CreateContainerResponse container1 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withCmd("sleep", "9999")
.withName(container1Name)
.withBinds(bind1, bind2)
.exec();
LOG.info("Created container1 {}", container1.toString());
InspectContainerResponse inspectContainerResponse1 = dockerRule.getClient().inspectContainerCmd(container1.getId())
.exec();
assertThat(Arrays.asList(inspectContainerResponse1.getHostConfig().getBinds()), containsInAnyOrder(bind1, bind2));
assertThat(inspectContainerResponse1, mountedVolumes(containsInAnyOrder(volume1, volume2)));
// create a second container with volumes from first container
CreateContainerResponse container2 = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withCmd("sleep", "9999")
.withVolumesFrom(new VolumesFrom(container1Name))
.exec();
LOG.info("Created container2 {}", container2.toString());
InspectContainerResponse inspectContainerResponse2 = dockerRule.getClient().inspectContainerCmd(container2.getId())
.exec();
// No volumes are created, the information is just stored in .HostConfig.VolumesFrom
assertThat(inspectContainerResponse2.getHostConfig().getVolumesFrom(),
hasItemInArray(new VolumesFrom(container1Name)));
assertThat(inspectContainerResponse1, mountedVolumes(containsInAnyOrder(volume1, volume2)));
// To ensure that the information stored in VolumesFrom really is considered
// when starting the container, we start it and verify that it has the same
// bind mounts as the first container.
// This is somehow out of scope here, but it helped me to understand how the
// VolumesFrom feature really works.
dockerRule.getClient().startContainerCmd(container2.getId()).exec();
LOG.info("Started container2 {}", container2.toString());
inspectContainerResponse2 = dockerRule.getClient().inspectContainerCmd(container2.getId()).exec();
assertThat(inspectContainerResponse2.getHostConfig().getVolumesFrom(), hasItemInArray(new VolumesFrom(
container1Name)));
assertThat(inspectContainerResponse2, mountedVolumes(containsInAnyOrder(volume1, volume2)));
}