Java Code Examples for com.github.dockerjava.api.command.InspectContainerResponse#Mount
The following examples show how to use
com.github.dockerjava.api.command.InspectContainerResponse#Mount .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerializableMount.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public SerializableMount(InspectContainerResponse.Mount mount) { if(mount != null) { this.name = mount.getName(); this.source = mount.getSource(); this.driver = mount.getDriver(); this.mode = mount.getMode(); this.rw = mount.getRW(); this.destination = mount.getDestination(); } }
Example 2
Source File: BrowserWebDriverContainerTest.java From testcontainers-java with MIT License | 5 votes |
@Test public void createContainerWithShmVolume() { try ( BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer() .withCapabilities(new FirefoxOptions()) ) { webDriverContainer.start(); final List<InspectContainerResponse.Mount> shmVolumes = shmVolumes(webDriverContainer); assertEquals("Only one shm mount present", 1, shmVolumes.size()); assertEquals("Shm mount source is correct", "/dev/shm", shmVolumes.get(0).getSource()); assertEquals("Shm mount mode is correct", "rw", shmVolumes.get(0).getMode()); } }
Example 3
Source File: BrowserWebDriverContainerTest.java From testcontainers-java with MIT License | 5 votes |
private List<InspectContainerResponse.Mount> shmVolumes(final BrowserWebDriverContainer container) { return container.getContainerInfo().getMounts() .stream() // destination path is always /dev/shm .filter(m -> m.getDestination().getPath().equals("/dev/shm")) .collect(toList()); }
Example 4
Source File: DockerMatchers.java From docker-java with Apache License 2.0 | 5 votes |
@Override public List<Volume> featureValueOf(InspectContainerResponse item) { List<Volume> volumes = new ArrayList<>(); for (InspectContainerResponse.Mount mount : item.getMounts()) { volumes.add(mount.getDestination()); } return volumes; }
Example 5
Source File: StartContainerCmdIT.java From docker-java with Apache License 2.0 | 2 votes |
@Test public void startContainerWithVolumes() throws Exception { // see http://docs.docker.io/use/working_with_volumes/ Volume volume1 = new Volume("/opt/webapp1"); Volume volume2 = new Volume("/opt/webapp2"); CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withVolumes(volume1, volume2) .withCmd("true") .withHostConfig(newHostConfig() .withBinds(new Bind("/tmp/webapp1", volume1, ro), new Bind("/tmp/webapp2", volume2))) .exec(); LOG.info("Created container {}", container.toString()); assertThat(container.getId(), not(is(emptyString()))); InspectContainerResponse inspectContainerResponse = dockerRule.getClient().inspectContainerCmd(container.getId()).exec(); assertThat(inspectContainerResponse.getConfig().getVolumes().keySet(), contains("/opt/webapp1", "/opt/webapp2")); dockerRule.getClient().startContainerCmd(container.getId()).exec(); dockerRule.getClient().waitContainerCmd(container.getId()).start().awaitStatusCode(); inspectContainerResponse = dockerRule.getClient().inspectContainerCmd(container.getId()).exec(); assertThat(inspectContainerResponse, mountedVolumes(containsInAnyOrder(volume1, volume2))); final List<InspectContainerResponse.Mount> mounts = inspectContainerResponse.getMounts(); assertThat(mounts, hasSize(2)); final InspectContainerResponse.Mount mount1 = new InspectContainerResponse.Mount() .withRw(false).withMode("ro").withDestination(volume1).withSource("/tmp/webapp1"); final InspectContainerResponse.Mount mount2 = new InspectContainerResponse.Mount() .withRw(true).withMode("rw").withDestination(volume2).withSource("/tmp/webapp2"); assertThat(mounts, containsInAnyOrder(mount1, mount2)); }