com.github.dockerjava.api.model.Bind.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中com.github.dockerjava.api.model.Bind.<init>()方法的一些代码示例,展示了Bind.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bind.<init>()方法的具体详情如下:
包路径:com.github.dockerjava.api.model.Bind
类名称:Bind
方法名:<init>

Bind.<init>介绍

暂无

代码示例

代码示例来源:origin: testcontainers/testcontainers-java

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) {
  6. final MountableFile mountableFile = MountableFile.forHostPath(hostPath);
  7. binds.add(new Bind(mountableFile.getResolvedPath(), new Volume(containerPath), mode.accessMode, selinuxContext.selContext));
  8. }

代码示例来源:origin: docker-java/docker-java

  1. switch (parts.length) {
  2. case 2: {
  3. return new Bind(parts[0], new Volume(parts[1]));
  4. return new Bind(parts[0], new Volume(parts[1]), accessMode, seMode, nocopy, propagationMode);

代码示例来源:origin: testcontainers/testcontainers-java

  1. private boolean checkMountableFile() {
  2. DockerClient dockerClient = client();
  3. MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class");
  4. Volume volume = new Volume("/dummy");
  5. try {
  6. return runInsideDocker(
  7. createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)),
  8. (__, containerId) -> {
  9. try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) {
  10. stream.read();
  11. return true;
  12. } catch (Exception e) {
  13. return false;
  14. }
  15. }
  16. );
  17. } catch (Exception e) {
  18. log.debug("Failure while checking for mountable file support", e);
  19. return false;
  20. }
  21. }

代码示例来源:origin: FlowCI/flow-platform

  1. .withBinds(new Bind(repoPath.toString(), volume),
  2. new Bind(Paths.get(repoPath.getParent().toString(), REPOSITORY).toString(), mvnVolume))
  3. .withWorkingDir(File.separator + fileName)
  4. .withCmd(BASH, "-c", cmd)

代码示例来源:origin: org.testcontainers/testcontainers

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public void addFileSystemBind(final String hostPath, final String containerPath, final BindMode mode, final SelinuxContext selinuxContext) {
  6. final MountableFile mountableFile = MountableFile.forHostPath(hostPath);
  7. binds.add(new Bind(mountableFile.getResolvedPath(), new Volume(containerPath), mode.accessMode, selinuxContext.selContext));
  8. }

代码示例来源:origin: stackoverflow.com

  1. void testServiceCallWithNoKeyPropertyFound() {
  2. Component componentUnderTest = new Component() {
  3. Integer getProperties(String key) {
  4. return null; // property should not be found
  5. }
  6. Request getRequest() {
  7. return new Request(...); //this request should not contain a property named "key",
  8. }
  9. Bind getBind() {
  10. return new Bind(...); //this bind should not contain a property named "key"
  11. }
  12. String makeServiceCall(String url) {
  13. if (url.endsWith("null")) {
  14. return success;
  15. }
  16. throw new AssertionError("expected url ending with null, but was " + url);
  17. }
  18. };
  19. componentUnderTest.activate();
  20. assertThat(componentUnderTest.getSomeString(), equalTo("success"));
  21. }

代码示例来源:origin: com.github.qzagarese/dockerunit-core

  1. @Override
  2. public CreateContainerCmd build(ServiceDescriptor sd, CreateContainerCmd cmd, Volume v) {
  3. Bind[] binds = cmd.getBinds();
  4. String hostPath = v.useClasspath()
  5. ? Thread.currentThread().getContextClassLoader()
  6. .getResource(v.host()).getPath()
  7. : v.host();
  8. Bind bind = new Bind(hostPath,
  9. new com.github.dockerjava.api.model.Volume(v.container()),
  10. AccessMode.fromBoolean(v.accessMode().equals(Volume.AccessMode.RW)));
  11. List<Bind> bindsList = new ArrayList<>();
  12. if(binds != null) {
  13. bindsList.addAll(Arrays.asList(binds));
  14. }
  15. bindsList.add(bind);
  16. return cmd.withBinds(bindsList);
  17. }

代码示例来源:origin: com.github.docker-java/docker-java

  1. switch (parts.length) {
  2. case 2: {
  3. return new Bind(parts[0], new Volume(parts[1]));
  4. return new Bind(parts[0], new Volume(parts[1]), accessMode, seMode, nocopy, propagationMode);

代码示例来源:origin: Kurento/kurento-java

  1. .withBinds(new Bind(hostConfigFilePath, configVol));
  2. new Bind(testFilesPath, testFilesVolume, AccessMode.ro),
  3. new Bind(workspacePath, workspaceVolume, AccessMode.rw),
  4. new Bind(configFilePath, configVol));
  5. } else {
  6. new Bind(testFilesPath, testFilesVolume, AccessMode.ro),
  7. new Bind(workspacePath, workspaceVolume, AccessMode.rw));

代码示例来源:origin: org.kurento/kurento-test

  1. .withBinds(new Bind(hostConfigFilePath, configVol));
  2. new Bind(testFilesPath, testFilesVolume, AccessMode.ro),
  3. new Bind(workspacePath, workspaceVolume, AccessMode.rw),
  4. new Bind(configFilePath, configVol));
  5. } else {
  6. new Bind(testFilesPath, testFilesVolume, AccessMode.ro),
  7. new Bind(workspacePath, workspaceVolume, AccessMode.rw));

代码示例来源:origin: org.kurento/kurento-test

  1. public void mountFiles(CreateContainerCmd createContainerCmd) {
  2. String videoFilesDiskPath = "/var/lib/jenkins/test-files";
  3. Volume configVol = new Volume(KurentoTest.getTestFilesDiskPath());
  4. createContainerCmd.withVolumes(configVol).withBinds(new Bind(videoFilesDiskPath, configVol));
  5. }

代码示例来源:origin: Kurento/kurento-java

  1. public void mountFiles(CreateContainerCmd createContainerCmd) {
  2. String videoFilesDiskPath = "/var/lib/jenkins/test-files";
  3. Volume configVol = new Volume(KurentoTest.getTestFilesDiskPath());
  4. createContainerCmd.withVolumes(configVol).withBinds(new Bind(videoFilesDiskPath, configVol));
  5. }

代码示例来源:origin: org.testcontainers/testcontainers

  1. private boolean checkMountableFile() {
  2. DockerClient dockerClient = client();
  3. MountableFile mountableFile = MountableFile.forClasspathResource(ResourceReaper.class.getName().replace(".", "/") + ".class");
  4. Volume volume = new Volume("/dummy");
  5. try {
  6. return runInsideDocker(createContainerCmd -> createContainerCmd.withBinds(new Bind(mountableFile.getResolvedPath(), volume, AccessMode.ro)), (__, containerId) -> {
  7. try (InputStream stream = dockerClient.copyArchiveFromContainerCmd(containerId, volume.getPath()).exec()) {
  8. stream.read();
  9. return true;
  10. } catch (Exception e) {
  11. return false;
  12. }
  13. });
  14. } catch (Exception e) {
  15. log.debug("Failure while checking for mountable file support", e);
  16. return false;
  17. }
  18. }

代码示例来源:origin: org.testcontainers/testcontainers

  1. DockerClientFactory.instance().checkAndPullImage(client, ryukImage);
  2. List<Bind> binds = new ArrayList<>();
  3. binds.add(new Bind("//var/run/docker.sock", new Volume("/var/run/docker.sock")));
  4. 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();
  5. client.startContainerCmd(ryukContainerId).exec();

代码示例来源:origin: com.alexecollins.docker/docker-java-orchestration-core

  1. if (hostPath!=null && !hostPath.trim().equals("")){
  2. logger.info(" - volumes " + volumePath + " <- " + hostPath);
  3. binds.add(new Bind(hostPath, volume));
  4. } else {
  5. volumes.add(volume);

代码示例来源:origin: org.alien4cloud.puccini/puccini-docker

  1. .withPortBindings(portBindings);
  2. if (volumes != null && !volumes.isEmpty()) {
  3. createContainerCmd.withBinds(volumes.stream().map(volume -> new Bind(volume.getVolumeId(), new com.github.dockerjava.api.model.Volume(volume.getLocation()))).collect(Collectors.toList()));

代码示例来源:origin: gradle.plugin.com.dimafeng/containerized-tasks

  1. .withCmd(command)
  2. .withBinds(volumeBinds.entrySet().stream()
  3. .map(e -> new Bind(e.getKey(), new Volume(e.getValue())))
  4. .collect(toList())

代码示例来源:origin: ioFog/Agent

  1. accessMode = AccessMode.DEFAULT;
  2. volumeBindings.add(new Bind(volumeMapping.getHostDestination(), volume, accessMode));
  3. });

代码示例来源:origin: emc-mongoose/mongoose

  1. final Volume volume = new Volume(containerPath);
  2. volumes.add(volume);
  3. final Bind bind = new Bind(hostPath.toString(), volume);
  4. binds.add(bind);
  5. });

代码示例来源:origin: vmware/xenon

  1. Binds binds = new Binds(new Bind(this.containerBindingPath, new Volume(this.containerBindingPath)));
  2. hostConfig.withBinds(binds);

相关文章