英文:
How to create container with named volume?
问题
使用docker-java库如何创建带有命名Docker卷的容器?
英文:
How to create container with named docker volume using the docker-java library?
答案1
得分: 4
好的,我找到了解决方案:
Volume newVolume = new Volume("/target");
Bind bind = new Bind(namedVolumeName, newVolume);
CreateContainerResponse container = dockerClient.createContainerCmd(imageId)
.withName(containerName)
.withHostConfig(HostConfig.newHostConfig().withBinds(bind))
.exec();
英文:
Ok, I found solution:
Volume newVolume = new Volume("/target");
Bind bind = new Bind(namedVolumeName, newVolume);
CreateContainerResponse container = dockerClient.createContainerCmd(imageId)
.withName(containerName)
.withHostConfig(HostConfig.newHostConfig().withBinds(bind))
.exec();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论