本文整理了Java中com.github.dockerjava.api.model.Bind
类的一些代码示例,展示了Bind
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bind
类的具体详情如下:
包路径:com.github.dockerjava.api.model.Bind
类名称:Bind
[英]Represents a host path being bind mounted as a Volume in a Docker container. The Bind can be in read only or read write access mode.
[中]表示正在作为卷绑定装入Docker容器中的主机路径。绑定可以处于只读或读写访问模式。
代码示例来源: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
@Override
public Binds deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
List<Bind> binds = new ArrayList<Bind>();
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
for (Iterator<JsonNode> it = node.elements(); it.hasNext();) {
JsonNode field = it.next();
binds.add(Bind.parse(field.asText()));
}
return new Binds(binds.toArray(new Bind[0]));
}
}
代码示例来源:origin: docker-java/docker-java
@Override
public boolean equals(Object obj) {
if (obj instanceof Bind) {
Bind other = (Bind) obj;
return new EqualsBuilder()
.append(path, other.getPath())
.append(volume, other.getVolume())
.append(accessMode, other.getAccessMode())
.append(secMode, other.getSecMode())
.append(noCopy, other.getNoCopy())
.append(propagationMode, other.getPropagationMode())
.isEquals();
} else {
return super.equals(obj);
}
}
代码示例来源: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: arquillian/arquillian-cube
private static final Bind[] toBinds(Collection<String> bindsList) {
Bind[] binds = new Bind[bindsList.size()];
int i = 0;
for (String bind : bindsList) {
binds[i] = Bind.parse(bind);
i++;
}
return binds;
}
代码示例来源:origin: com.github.docker-java/docker-java
@Override
public boolean equals(Object obj) {
if (obj instanceof Bind) {
Bind other = (Bind) obj;
return new EqualsBuilder()
.append(path, other.getPath())
.append(volume, other.getVolume())
.append(accessMode, other.getAccessMode())
.append(secMode, other.getSecMode())
.append(noCopy, other.getNoCopy())
.append(propagationMode, other.getPropagationMode())
.isEquals();
} else {
return super.equals(obj);
}
}
代码示例来源: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: org.arquillian.cube/arquillian-cube-docker
private static final Bind[] toBinds(Collection<String> bindsList) {
Bind[] binds = new Bind[bindsList.size()];
int i = 0;
for (String bind : bindsList) {
binds[i] = Bind.parse(bind);
i++;
}
return binds;
}
代码示例来源: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: jenkinsci/docker-build-step-plugin
private static Bind parseOneBind(String definition) throws IllegalArgumentException {
try {
// first try as-is (using ":" as delimiter) in order to
// preserve whitespace in paths
return Bind.parse(definition);
} catch (IllegalArgumentException e1) {
try {
// give it a second try assuming blanks as delimiter
return Bind.parse(definition.replace(' ', ':'));
} catch (Exception e2) {
throw new IllegalArgumentException(
"Bind mount needs to be in format 'hostPath containerPath[ rw|ro]'");
}
}
}
代码示例来源: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: com.github.docker-java/docker-java
@Override
public Binds deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
List<Bind> binds = new ArrayList<Bind>();
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
for (Iterator<JsonNode> it = node.elements(); it.hasNext();) {
JsonNode field = it.next();
binds.add(Bind.parse(field.asText()));
}
return new Binds(binds.toArray(new Bind[0]));
}
}
代码示例来源: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: jenkinsci/docker-plugin
public FormValidation doCheckVolumesString(@QueryParameter String volumesString) {
try {
final String[] strings = splitAndFilterEmpty(volumesString, "\n");
for (String s : strings) {
if (s.equals("/")) {
return FormValidation.error("Invalid volume: path can't be '/'");
}
final String[] group = s.split(":");
if (group.length > 3) {
return FormValidation.error("Wrong syntax: " + s);
} else if (group.length == 2 || group.length == 3) {
if (group[1].equals("/")) {
return FormValidation.error("Invalid bind mount: destination can't be '/'");
}
Bind.parse(s);
} else if (group.length == 1) {
new Volume(s);
} else {
return FormValidation.error("Wrong line: " + s);
}
}
} catch (Throwable t) {
return FormValidation.error(t.getMessage());
}
return FormValidation.ok();
}
代码示例来源: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: ContainerSolutions/minimesos
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;
}
代码示例来源: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: ContainerSolutions/minimesos
@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());
}
代码示例来源: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: jenkinsci/docker-plugin
binds.add(Bind.parse(vol));
} else if (vol.equals("/")) {
throw new IllegalArgumentException("Invalid volume: path can't be '/'");
内容来源于网络,如有侵权,请联系作者删除!