如何使用docker-java library使用命名的docker卷创建容器?
答案 0 :(得分:2)
好的,我找到了解决方法:
Volume newVolume = new Volume("/target");
Bind bind = new Bind(namedVolumeName, newVolume);
CreateContainerResponse container = dockerClient.createContainerCmd(imageId)
.withName(containerName)
.withHostConfig(HostConfig.newHostConfig().withBinds(bind))
.exec();