我按照spotify-docker-client用户手册和github问题配置特定内存,但我收到此错误 {"message":"Minimum memory limit allowed is 6MB"} 我有以下代码的 spring boot 项目
@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;
}