1

How to create container with named docker volume using the docker-java library?

Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
Gavlos
  • 197
  • 1
  • 14

1 Answers1

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