Testcontainers-java: Question regarding deprecated methods

Created on 18 May 2020  路  5Comments  路  Source: testcontainers/testcontainers-java

I have found a very nice method ...withCreateContainerCmdModifier(cmd -> cmd.withCpusetCpus("0-4")); which exactly solves our problem related to an Oracle XE container (does not run on an machine with 48 core's). Unfortunately the withCpusetCpus method is marked deprecated.

Questions:

  • My assumption is that those deprecated methods will be removed with release 2.X of testcontainers? Or does there exist an documentation about that?
  • Does exists a better way to run a docker container with cpuset (docker run --cpuset-cpus string ...) limitation which I might not have seen yet in Testcontainers?
typquestion

All 5 comments

Hi @khmarbaise,

This method is from docker-java, not Testcontainers. As many other methods on CreateContainerCmd, they are aliases to getHostConfig().withCpusetCpus("0-4") (not deprecated). They were deprecated to keep CreateContainerCmd interface small and better aligned with the Docker API where such methods only exist on HostConfig object and not CreateContainerCmd payload.

Hi @bsideup,
first thanks for your hint regarding the docker-java. One question kept: Is there a better solution not to go via withCreateContainerCmdModifier(cmd -> cmd.withCpusetCpus("0-4"));.

Unfortunately I haven't seen a way to get the HostConfig and set the cpuset there (Maybe I'm just blind).
Currently we are using:

new GenericContainer<>(getDatabaseImage()).withExposedPorts(...)
        .withStartupAttempts(..)
        .withStartupTimeout(..)
        .withCreateContainerCmdModifier(cmd -> cmd.withCpusetCpus("0-4"));

@khmarbaise
you can use the same method:

.withCreateContainerCmdModifier(cmd -> {
    cmd.getHostConfig().withCpusetCpus("0-4");
});

Hi @bsideup, outch Ok ...I was blind. Many thanks for your help.

@khmarbaise happy to help! :)

Was this page helpful?
0 / 5 - 0 ratings