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


Java InspectContainerResponse.getHostConfig方法代码示例

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


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

示例1: setExposed

import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
@Override
public void setExposed(Instance instance, Map<String, Object> fromInspect) {
    InspectContainerResponse inspect = transformInspect(fromInspect);
    ContainerConfig containerConfig = inspect.getConfig();
    HostConfig hostConfig = inspect.getHostConfig();

    if (containerConfig != null && hostConfig != null) {
        setExposed(instance, safeGetExposedPorts(containerConfig));
    }

}
 
开发者ID:rancher,项目名称:cattle,代码行数:12,代码来源:DockerTransformerImpl.java

示例2: updateContainer

import com.github.dockerjava.api.command.InspectContainerResponse; //导入方法依赖的package包/类
@Test
    public void updateContainer() throws DockerException, IOException {
        assumeThat("API version should be >= 1.22", dockerRule, isGreaterOrEqual(VERSION_1_22));

        CreateContainerResponse response = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
                .withCmd("sleep", "9999")
                .exec();

        String containerId = response.getId();
        dockerRule.getClient().startContainerCmd(containerId).exec();

        InspectContainerResponse inspectBefore = dockerRule.getClient().inspectContainerCmd(containerId).exec();
        LOG.debug("Inspect: {}", inspectBefore);
        final Long memory = inspectBefore.getHostConfig().getMemory();

        final UpdateContainerResponse updateResponse = dockerRule.getClient().updateContainerCmd(containerId)
                .withBlkioWeight(300)
                .withCpuShares(512)
                .withCpuPeriod(100000)
                .withCpuQuota(50000)
//                .withCpusetCpus("0") // depends on env
                .withCpusetMems("0")
//                .withMemory(209715200L + 2L)
//                .withMemorySwap(514288000L) Your kernel does not support swap limit capabilities, memory limited without swap.
//                .withMemoryReservation(209715200L)
//                .withKernelMemory(52428800) Can not update kernel memory to a running container, please stop it first.
                .exec();

        // true only on docker toolbox (1.10.1)
//        assertThat(updateResponse.getWarnings(), hasSize(1));
//        assertThat(updateResponse.getWarnings().get(0),
//                is("Your kernel does not support Block I/O weight. Weight discarded."));

        InspectContainerResponse inspectAfter = dockerRule.getClient().inspectContainerCmd(containerId).exec();
        final HostConfig afterHostConfig = inspectAfter.getHostConfig();

//        assertThat(afterHostConfig.getMemory(), is(209715200L + 2L));

//        assertThat(afterHostConfig.getBlkioWeight(), is(300));
        assertThat(afterHostConfig.getCpuShares(), is(512));
        assertThat(afterHostConfig.getCpuPeriod(), is(100000));
        assertThat(afterHostConfig.getCpuQuota(), is(50000));
        assertThat(afterHostConfig.getCpusetMems(), is("0"));

//        assertThat(afterHostConfig.getMemoryReservation(), is(209715200L));
//       assertThat(afterHostConfig.getMemorySwap(), is(514288000L));

    }
 
开发者ID:docker-java,项目名称:docker-java,代码行数:49,代码来源:UpdateContainerCmdIT.java


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