Skip to content

Update docs - Setting the --memory and --memory-swap option for containers #2510

@tschmidt01

Description

@tschmidt01

The documentation site states, that the --memory and --memory-swap options can be set as

@Rule
public GenericContainer memoryLimitedRedis = new GenericContainer<>("redis:3.0.2")
        .withCreateContainerCmdModifier(cmd -> cmd.withMemory((long) 8 * 1024 * 1024))
        .withCreateContainerCmdModifier(cmd -> cmd.withMemorySwap((long) 12 * 1024 * 1024));

though both got deprecated in docker-java/docker-java#1291 as this should be done via withHostConfig now:

private HostConfig hostConfig = HostConfig.newHostConfig()
    .withMemory((long) 8 * 1024 * 1024)
    .withMemorySwap((long) 12 * 1024 * 1024);
    
@Rule
public GenericContainer memoryLimitedRedis = new GenericContainer<>("redis:3.0.2")
        .withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(hostConfig);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions