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; } }
createCommand.withBinds(bindsArray);
.withBinds(new Bind(repoPath.toString(), volume), new Bind(Paths.get(repoPath.getParent().toString(), REPOSITORY).toString(), mvnVolume)) .withWorkingDir(File.separator + fileName)
@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); }
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; } }
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(); InspectContainerResponse inspectedContainer = client.inspectContainerCmd(ryukContainerId).exec();
.withBinds(new Bind(hostConfigFilePath, configVol)); .withBinds( new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw), } else { createContainerCmd.withVolumes(testFilesVolume, workspaceVolume, dockerSock).withBinds( new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw));
.withBinds(new Bind(hostConfigFilePath, configVol)); .withBinds( new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw), } else { createContainerCmd.withVolumes(testFilesVolume, workspaceVolume, dockerSock).withBinds( new Bind(testFilesPath, testFilesVolume, AccessMode.ro), new Bind(workspacePath, workspaceVolume, AccessMode.rw));
.withLabels(labels) .withEnv(environmentAssignments) .withBinds(volumeBinds) .withUlimits(ulimits) .withCapAdd(new ArrayList<>(addCapabilities))
cmd.withBinds(binds.toArray(new Bind[binds.size()]));
@Override protected CreateContainerCmd dockerCommand() { return DockerClientFactory.build().createContainerCmd(config.getImageName() + ":" + config.getImageTag()) .withNetworkMode("host") .withBinds(Bind.parse("/var/run/docker.sock:/tmp/docker.sock")) .withCmd("-internal", String.format("consul://%s:%d", consul.getIpAddress(), ConsulConfig.CONSUL_HTTP_PORT)) .withName(getName()); }
createCommand.withBinds(bindsArray); VolumesFrom[] volumesFromsArray = volumesFroms.stream().toArray(VolumesFrom[]::new); createCommand.withVolumesFrom(volumesFromsArray);
.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()));
private CreateContainerCmd getBaseCommand() { String hostDir = MesosCluster.getClusterHostDir().getAbsolutePath(); List<Bind> binds = new ArrayList<>(); binds.add(Bind.parse("/var/run/docker.sock:/var/run/docker.sock:rw")); binds.add(Bind.parse("/sys/fs/cgroup:/sys/fs/cgroup")); binds.add(Bind.parse(hostDir + ":" + hostDir)); if (getCluster().getMapAgentSandboxVolume()) { binds.add(Bind.parse(String.format("%s:%s:rw", hostDir + "/.minimesos/sandbox-" + getClusterId() + "/" + hostName, MESOS_AGENT_WORK_DIR + hostName + "/slaves"))); } CreateContainerCmd cmd = DockerClientFactory.build().createContainerCmd(getImageName() + ":" + getImageTag()) .withName(getName()) .withHostName(hostName) .withPrivileged(true) .withVolumes(new Volume(MESOS_AGENT_WORK_DIR + hostName)) .withEnv(newEnvironment() .withValues(getMesosAgentEnvVars()) .withValues(getSharedEnvVars()) .createEnvironment()) .withPidMode("host") .withLinks(new Link(getZooKeeper().getContainerId(), "minimesos-zookeeper")) .withBinds(binds.stream().toArray(Bind[]::new)); MesosDns mesosDns = getCluster().getMesosDns(); if (mesosDns != null) { cmd.withDns(mesosDns.getIpAddress()); } return cmd; }
.withWorkingDir(workingDir) .withCmd(command) .withBinds(volumeBinds.entrySet().stream() .map(e -> new Bind(e.getKey(), new Volume(e.getValue()))) .collect(toList())
cmd = cmd .withVolumes(volumes.toArray(new Volume[volumes.size()])) .withBinds(volumeBindings.toArray(new Bind[volumeBindings.size()]));
Paths.get(KurentoTest.getDefaultOutputFolder().toURI()).toAbsolutePath().toString(); Volume volumeTest = new Volume(targetPath); createContainerCmd.withVolumes(volume, volumeTest).withBinds( new Bind(testFilesPath, volume, AccessMode.ro), new Bind(targetPath, volumeTest, AccessMode.rw));
cfgCmd.withBinds(BindParser.parse(bindMountsRes));