How to create container with named docker volume using the docker-java library?
Asked
Active
Viewed 305 times
1 Answers
4
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();

Giorgi Tsiklauri
- 9,715
- 8
- 45
- 66

Gavlos
- 197
- 1
- 14
-
Dude I love you. If I could give you more than one upvote I would! Thanks!!! – Luis Lavieri Aug 18 '22 at 22:30