(DockerClient client, String localIp, String proto)
| 113 | } |
| 114 | |
| 115 | public void createContainer(DockerClient client, String localIp, String proto) { |
| 116 | InspectVolumeCmd inspectVolume = client.inspectVolumeCmd(volumeName); |
| 117 | try { |
| 118 | |
| 119 | inspectVolume.exec(); |
| 120 | } catch (NotFoundException e) { |
| 121 | |
| 122 | // create volume |
| 123 | client.createVolumeCmd().withName(volumeName).exec(); |
| 124 | } |
| 125 | |
| 126 | InspectContainerCmd inspect = client.inspectContainerCmd(containerName); |
| 127 | try { |
| 128 | |
| 129 | inspect.exec(); |
| 130 | } catch (NotFoundException e) { |
| 131 | |
| 132 | // create container |
| 133 | HostConfig hostConfig = new HostConfig().withBinds(new Bind(volumeName, new Volume("/opt"))) |
| 134 | .withPortBindings(new Ports(PortBinding.parse("0.0.0.0:1194:1194/udp"), |
| 135 | PortBinding.parse("0.0.0.0:1194:1194/tcp"), PortBinding.parse("0.0.0.0:18080:8080/tcp"))) |
| 136 | .withCapAdd(Capability.NET_ADMIN); |
| 137 | |
| 138 | client.createContainerCmd(imageName).withName(containerName).withHostConfig(hostConfig) |
| 139 | .withExposedPorts(new ExposedPort(1194)).withEnv("HOST_ADDR=" + localIp).exec(); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | public void startContainer(DockerClient client, String proto) { |
| 144 | InspectContainerResponse inspect = client.inspectContainerCmd(containerName).exec(); |
no test coverage detected