如何创建具有命名卷的容器?

Gav*_*los 1 java docker-api

如何使用docker-java 库创建具有命名 docker 卷的容器?

Gav*_*los 5

好的,我找到了解决方案:

Volume newVolume = new Volume("/target");

Bind bind = new Bind(namedVolumeName, newVolume);

CreateContainerResponse container = dockerClient.createContainerCmd(imageId)
    .withName(containerName)
    .withHostConfig(HostConfig.newHostConfig().withBinds(bind))
    .exec();
Run Code Online (Sandbox Code Playgroud)