mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: docker-java library update to 3.1.1
parent
c282d53349
commit
52cad41294
|
@ -267,7 +267,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.docker-java</groupId>
|
||||
<artifactId>docker-java</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<version>3.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.openvidu</groupId>
|
||||
|
|
|
@ -146,7 +146,11 @@ public class RecordingManager {
|
|||
}
|
||||
});
|
||||
t.start();
|
||||
dockerManager.downloadDockerImage(IMAGE_NAME + ":" + IMAGE_TAG);
|
||||
try {
|
||||
dockerManager.downloadDockerImage(IMAGE_NAME + ":" + IMAGE_TAG, 600);
|
||||
} catch (Exception e) {
|
||||
log.error("Error downloading docker image {}:{}", IMAGE_NAME, IMAGE_TAG);
|
||||
}
|
||||
t.interrupt();
|
||||
try {
|
||||
t.join();
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.github.dockerjava.api.exception.InternalServerErrorException;
|
|||
import com.github.dockerjava.api.exception.NotFoundException;
|
||||
import com.github.dockerjava.api.model.Bind;
|
||||
import com.github.dockerjava.api.model.Container;
|
||||
import com.github.dockerjava.api.model.HostConfig;
|
||||
import com.github.dockerjava.api.model.Volume;
|
||||
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
||||
import com.github.dockerjava.core.DockerClientBuilder;
|
||||
|
@ -58,9 +59,10 @@ public class DockerManager {
|
|||
this.dockerClient = DockerClientBuilder.getInstance(config).build();
|
||||
}
|
||||
|
||||
public void downloadDockerImage(String image) {
|
||||
public void downloadDockerImage(String image, int secondsOfWait) throws Exception {
|
||||
try {
|
||||
this.dockerClient.pullImageCmd(image).exec(new PullImageResultCallback()).awaitSuccess();
|
||||
this.dockerClient.pullImageCmd(image).exec(new PullImageResultCallback()).awaitCompletion(secondsOfWait,
|
||||
TimeUnit.SECONDS);
|
||||
} catch (NotFoundException | InternalServerErrorException e) {
|
||||
if (dockerImageExistsLocally(image)) {
|
||||
log.info("Docker image '{}' exists locally", image);
|
||||
|
@ -70,6 +72,9 @@ public class DockerManager {
|
|||
} catch (DockerClientException e) {
|
||||
log.info("Error on Pulling '{}' image. Probably because the user has stopped the execution", image);
|
||||
throw e;
|
||||
} catch (InterruptedException e) {
|
||||
log.info("Error on Pulling '{}' image. Thread was interrupted: {}", image, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,8 +117,9 @@ public class DockerManager {
|
|||
|
||||
public String runContainer(String container, String containerName, List<Volume> volumes, List<Bind> binds,
|
||||
List<String> envs) throws Exception {
|
||||
HostConfig hostConfig = new HostConfig().withNetworkMode("host").withBinds(binds);
|
||||
CreateContainerCmd cmd = dockerClient.createContainerCmd(container).withName(containerName).withEnv(envs)
|
||||
.withNetworkMode("host").withVolumes(volumes).withBinds(binds);
|
||||
.withHostConfig(hostConfig).withVolumes(volumes);
|
||||
CreateContainerResponse response = null;
|
||||
try {
|
||||
response = cmd.exec();
|
||||
|
|
Loading…
Reference in New Issue