当前位置: 首页>>代码示例>>Java>>正文


Java CreateContainerCmd.withDns方法代码示例

本文整理汇总了Java中com.github.dockerjava.api.command.CreateContainerCmd.withDns方法的典型用法代码示例。如果您正苦于以下问题:Java CreateContainerCmd.withDns方法的具体用法?Java CreateContainerCmd.withDns怎么用?Java CreateContainerCmd.withDns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.dockerjava.api.command.CreateContainerCmd的用法示例。


在下文中一共展示了CreateContainerCmd.withDns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dockerCommand

import com.github.dockerjava.api.command.CreateContainerCmd; //导入方法依赖的package包/类
@Override
protected CreateContainerCmd dockerCommand() {
    int port = getServicePort();
    ExposedPort exposedPort = ExposedPort.tcp(port);

    Ports portBindings = new Ports();
    if (getCluster().isMapPortsToHost()) {
        portBindings.bind(exposedPort, Ports.Binding.bindPort(port));
    }

    CreateContainerCmd cmd = DockerClientFactory.build().createContainerCmd(getImageName() + ":" + getImageTag())
        .withName(getName())
        .withExposedPorts(new ExposedPort(getServicePort()))
        .withEnv(newEnvironment()
            .withValues(getMesosMasterEnvVars())
            .withValues(getSharedEnvVars())
            .createEnvironment())
        .withPortBindings(portBindings);

    MesosDns mesosDns = getCluster().getMesosDns();
    if (mesosDns != null) {
        cmd.withDns(mesosDns.getIpAddress());
    }

    return cmd;
}
 
开发者ID:ContainerSolutions,项目名称:minimesos,代码行数:27,代码来源:MesosMasterContainer.java

示例2: getBaseCommand

import com.github.dockerjava.api.command.CreateContainerCmd; //导入方法依赖的package包/类
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;
}
 
开发者ID:ContainerSolutions,项目名称:minimesos,代码行数:30,代码来源:MesosAgentContainer.java

示例3: call

import com.github.dockerjava.api.command.CreateContainerCmd; //导入方法依赖的package包/类
public String call() throws Exception {
    DockerClient client = DockerCommand.getClient(descriptor, cfgData.dockerUrlRes, cfgData.dockerVersionRes, cfgData.dockerCertPathRes, null);
    
    CreateContainerCmd cfgCmd = client.createContainerCmd(imageRes);
    if (commandRes != null) {
        cfgCmd.withCmd(commandRes);
    }
    cfgCmd.withHostName(hostNameRes);
    cfgCmd.withName(containerNameRes);
    HostConfig hc = new HostConfig();
    cfgCmd.withLinks(LinkUtils.parseLinks(linksRes).getLinks());
    if (envVarsRes != null) {
        cfgCmd.withEnv(envVarsRes);
    }
    if (exposedPortsRes != null && !exposedPortsRes.isEmpty()) {
    	final ExposedPort[] ports;
        String[] exposedPortsSplitted = exposedPortsRes.split(",");
        ports = new ExposedPort[exposedPortsSplitted.length];
        for (int i = 0; i < ports.length; i++) {
            ports[i] = ExposedPort.parse(exposedPortsSplitted[i]);
        }

    	cfgCmd.withExposedPorts(ports);
    }
    if (cpuSharesRes != null) {
        cfgCmd.withCpuShares(cpuSharesRes);
    }
    if (memoryLimitRes != null) {
        cfgCmd.withMemory(memoryLimitRes);
    }
    if (dnsRes != null) {
        cfgCmd.withDns(dnsRes);
    }
    if (extraHostsRes != null) {
        cfgCmd.withExtraHosts(extraHostsRes);
    }
    if (portBindingsRes != null) {
        cfgCmd.withPortBindings(PortBindingParser.parse(portBindingsRes));
    }
    if (bindMountsRes != null) {
        cfgCmd.withBinds(BindParser.parse(bindMountsRes));
    }
    if (alwaysRestart) {
        cfgCmd.withRestartPolicy(RestartPolicy.alwaysRestart());
    }
    
    CreateContainerResponse resp = cfgCmd.withPublishAllPorts(publishAllPorts).withPrivileged(privileged).exec();
    InspectContainerResponse inspectResp = client.inspectContainerCmd(resp.getId()).exec();
    
    ObjectMapper mapper = new ObjectMapper();
    String serialized = mapper.writeValueAsString(inspectResp);
    return serialized;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:54,代码来源:CreateContainerRemoteCallable.java


注:本文中的com.github.dockerjava.api.command.CreateContainerCmd.withDns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。