MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / createContainer

Method createContainer

src/main/java/core/packetproxy/OpenVPN.java:115–141  ·  view source on GitHub ↗
(DockerClient client, String localIp, String proto)

Source from the content-addressed store, hash-verified

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();

Callers 1

startServerMethod · 0.95

Calls 2

withNameMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected