本文整理匯總了Java中com.spotify.docker.client.messages.mount.Mount類的典型用法代碼示例。如果您正苦於以下問題:Java Mount類的具體用法?Java Mount怎麽用?Java Mount使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Mount類屬於com.spotify.docker.client.messages.mount包,在下文中一共展示了Mount類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldBuildMountFromDockerMount
import com.spotify.docker.client.messages.mount.Mount; //導入依賴的package包/類
@Test
public void shouldBuildMountFromDockerMount() throws Exception {
final DockerMounts dockerMounts = DockerMounts.fromString("source=namedVolume, target=/path/in/container\ntype=bind, src=/path/in/host, target=/path/in/container2, readonly");
final Volume volume = mock(Volume.class);
when(volume.name()).thenReturn("namedVolume");
final List<Mount> mounts = dockerMounts.toMount(asList(volume));
assertThat(mounts, hasSize(2));
assertThat(mounts.get(0).type(), is("volume"));
assertThat(mounts.get(0).source(), is("namedVolume"));
assertThat(mounts.get(0).target(), is("/path/in/container"));
assertThat(mounts.get(0).readOnly(), is(false));
assertThat(mounts.get(1).type(), is("bind"));
assertThat(mounts.get(1).source(), is("/path/in/host"));
assertThat(mounts.get(1).target(), is("/path/in/container2"));
assertThat(mounts.get(1).readOnly(), is(true));
}
示例2: shouldStartContainerWithMountedVolume
import com.spotify.docker.client.messages.mount.Mount; //導入依賴的package包/類
@Test
public void shouldStartContainerWithMountedVolume() throws Exception {
requireDockerApiVersionAtLeast("1.26", "Docker volume mount.");
final String volumeName = UUID.randomUUID().toString();
final Volume volume = docker.createVolume(Volume.builder()
.name(volumeName)
.driver("local")
.labels(Collections.singletonMap("cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerPlugin", ""))
.build()
);
Map<String, String> properties = new HashMap<>();
properties.put("Image", "alpine:latest");
properties.put("Mounts", "source=" + volumeName + ", target=/path/in/container");
DockerService service = DockerService.create(new CreateAgentRequest("key", properties, "prod", new JobIdentifier(100L)), createSettings(), docker);
services.add(service.name());
final Service inspectServiceInfo = docker.inspectService(service.name());
final Mount mount = inspectServiceInfo.spec().taskTemplate().containerSpec().mounts().get(0);
assertThat(mount.source(), is(volumeName));
assertThat(mount.type(), is("volume"));
}
示例3: toMount
import com.spotify.docker.client.messages.mount.Mount; //導入依賴的package包/類
public List<Mount> toMount(List<Volume> volumes) {
if (Util.isEmpty(volumes)) {
LOG.debug("No volumes to mount.");
return Collections.emptyList();
}
final Map<String, Volume> volumeMap = volumes.stream().collect(Collectors.toMap(o -> o.name(), o -> o));
final List<Mount> mounts = new ArrayList<>();
for (DockerMount dockerMount : this) {
if (dockerMount.type().equals("volume")) {
final Volume volume = volumeMap.get(dockerMount.source);
if (volume == null) {
throw new RuntimeException(format("Volume with name `{0}` does not exist.", dockerMount.source()));
}
LOG.debug(format("Using volume `{0}`.", dockerMount.source()));
}
final Mount mount = Mount.builder()
.type(dockerMount.type())
.source(dockerMount.source())
.target(dockerMount.target())
.readOnly(dockerMount.readOnly())
.build();
mounts.add(mount);
}
return mounts;
}