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

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

本文整理了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

/**
 * {@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));
}

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

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

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

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;
  }
}

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

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

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

/**
 * {@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));
}

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

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"));
}

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

@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);
}

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

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

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

.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));

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

.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));

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

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));
}

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

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));
}

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

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;
  }
}

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

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();

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

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

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

.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()));

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

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

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

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

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

final Volume volume = new Volume(containerPath);
 volumes.add(volume);
 final Bind bind = new Bind(hostPath.toString(), volume);
 binds.add(bind);
});

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

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

相关文章