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;

}
behrooz razzaghi
  • 105
  • 1
  • 1
  • 8
  • after some searching, i found the solution we should provide memory in byte , it is based on docker document [link](https://docs.docker.com/engine/api/v1.24/) "Memory - Memory limit in bytes" , – behrooz razzaghi Nov 30 '21 at 09:50

0 Answers0