2

I followed spotify-docker-client user manual and github issues to configure specific memory but i got this error {"message":"Minimum memory limit allowed is 6MB"} i have spring boot project with below code

@PostMapping(path = "/create")
public ContainerCreation Create(
                   @RequestParam("containerName") String containerName, //here i pass a name
                   @RequestParam("imageName") String imageName, // here i pass image id
                   @RequestParam("containerPort") int containerPort,// here i pass a port
                   @RequestParam("cpu") Long cpu,//here i pass cpu for example 1
                   @RequestParam("hostPort") int hostPort,// here i pass a port
                   @RequestParam("memory") Long memory // here i pass memory for example 500) throws DockerException, InterruptedException {

    final String[] ports = {String.valueOf(hostPort), String.valueOf(containerPort)};
    final Map<String, List<PortBinding>> portBindings = new HashMap<>();
    for (String port : ports) {
        List<PortBinding> hostPorts = new ArrayList<>();
        hostPorts.add(PortBinding.of("0.0.0.0", port));
        portBindings.put(port, hostPorts);
    }

    final HostConfig hostConfig = HostConfig.builder().portBindings(portBindings).cpuShares(cpu).memory(memory).build();
    final ContainerConfig containerConfig = ContainerConfig.builder()
            .hostConfig(hostConfig)
            .hostname(containerName)
            .image(imageName).exposedPorts(ports)
            .build();
    final ContainerCreation creation = dockerClientInstance.createContainer(containerConfig);

    return creation;

}
1
  • after some searching, i found the solution we should provide memory in byte , it is based on docker document link "Memory - Memory limit in bytes" , Commented Nov 30, 2021 at 9:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.