/** * {@inheritDoc} */ @Override public void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) { final MountableFile mountableFile = MountableFile.forHostPath(hostPath); binds.add(new Bind(mountableFile.getResolvedPath(), new Volume(containerPath), mode.accessMode, selinuxContext.selContext)); }
private boolean checkMountableFile() { DockerClient dockerClient = client(); MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class"); Volume volume = new Volume("/dummy"); try { return runInsideDocker( createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)), (__, containerId) -> { try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) { stream.read(); return true; } catch (Exception e) { return false; } } ); } catch (Exception e) { log.debug("Failure while checking for mountable file support", e); return false; } }
/** * {@inheritDoc} */ @Override public void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) { final MountableFile mountableFile = MountableFile.forHostPath(hostPath); binds.add(new Bind(mountableFile.getResolvedPath(), new Volume(containerPath), mode.accessMode, selinuxContext.selContext)); }
void testServiceCallWithNoKeyPropertyFound() { Component componentUnderTest = new Component() { Integer getProperties(String key) { return null; // property should not be found } Request getRequest() { return new Request(...); //this request should not contain a property named "key", } Bind getBind() { return new Bind(...); //this bind should not contain a property named "key" } String makeServiceCall(String url) { if (url.endsWith("null")) { return success; } throw new AssertionError("expected url ending with null, but was " + url); } }; componentUnderTest.activate(); assertThat(componentUnderTest.getSomeString(), equalTo("success")); }
@Override public CreateContainerCmd build(ServiceDescriptor sd, CreateContainerCmd cmd, Volume v) { Bind[] binds = cmd.getBinds(); String hostPath = v.useClasspath() ? Thread.currentThread().getContextClassLoader() .getResource(v.host()).getPath() : v.host(); Bind bind = new Bind(hostPath, new com.github.dockerjava.api.model.Volume(v.container()), AccessMode.fromBoolean(v.accessMode().equals(Volume.AccessMode.RW))); List<Bind> bindsList = new ArrayList<>(); if(binds != null) { bindsList.addAll(Arrays.asList(binds)); } bindsList.add(bind); return cmd.withBinds(bindsList); }
.withBinds(new Bind(hostConfigFilePath, configVol)); new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw), new Bind(configFilePath, configVol)); } else { new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw));
.withBinds(new Bind(hostConfigFilePath, configVol)); new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw), new Bind(configFilePath, configVol)); } else { new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw));
public void mountFiles(CreateContainerCmd createContainerCmd) { String videoFilesDiskPath = "/var/lib/jenkins/test-files"; Volume configVol = new Volume(KurentoTest.getTestFilesDiskPath()); createContainerCmd.withVolumes(configVol).withBinds(new Bind(videoFilesDiskPath, configVol)); }
public void mountFiles(CreateContainerCmd createContainerCmd) { String videoFilesDiskPath = "/var/lib/jenkins/test-files"; Volume configVol = new Volume(KurentoTest.getTestFilesDiskPath()); createContainerCmd.withVolumes(configVol).withBinds(new Bind(videoFilesDiskPath, configVol)); }
private boolean checkMountableFile() { DockerClient dockerClient = client(); MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class"); Volume volume = new Volume("/dummy"); try { return runInsideDocker(createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)), (__, containerId) -> { try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) { stream.read(); return true; } catch (Exception e) { return false; } }); } catch (Exception e) { log.debug("Failure while checking for mountable file support", e); return false; } }
DockerClientFactory.instance().checkAndPullImage(client, ryukImage); List<Bind> binds = new ArrayList<>(); binds.add(new Bind("//var/run/docker.sock", new Volume("/var/run/docker.sock"))); String ryukContainerId = client.createContainerCmd(ryukImage).withHostConfig(new HostConfig().withAutoRemove(true)).withExposedPorts(new ExposedPort(8080)).withPublishAllPorts(true).withName("testcontainers-ryuk-" + DockerClientFactory.SESSION_ID).withLabels(Collections.singletonMap(DockerClientFactory.TESTCONTAINERS_LABEL, "true")).withBinds(binds).withPrivileged(TestcontainersConfiguration.getInstance().isRyukPrivileged()).exec().getId(); client.startContainerCmd(ryukContainerId).exec();
if (hostPath!=null && !hostPath.trim().equals("")){ logger.info(" - volumes " + volumePath + " <- " + hostPath); binds.add(new Bind(hostPath, volume)); } else { volumes.add(volume);
.withPortBindings(portBindings); if (volumes != null && !volumes.isEmpty()) { createContainerCmd.withBinds(volumes.stream().map(volume -> new Bind(volume.getVolumeId(), new com.github.dockerjava.api.model.Volume(volume.getLocation()))).collect(Collectors.toList()));
.withCmd(command) .withBinds(volumeBinds.entrySet().stream() .map(e -> new Bind(e.getKey(), new Volume(e.getValue()))) .collect(toList())
accessMode = AccessMode.DEFAULT; volumeBindings.add(new Bind(volumeMapping.getHostDestination(), volume, accessMode)); });
final Volume volume = new Volume(containerPath); volumes.add(volume); final Bind bind = new Bind(hostPath.toString(), volume); binds.add(bind); });
Binds binds = new Binds(new Bind(this.containerBindingPath, new Volume(this.containerBindingPath))); hostConfig.withBinds(binds);