mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: Add labels and getLabels in DockerManager
parent
ac30d55a1e
commit
1d252e62ec
|
@ -175,7 +175,7 @@ public class ComposedRecordingService extends RecordingService {
|
|||
List<Bind> binds = new ArrayList<>();
|
||||
binds.add(bind1);
|
||||
containerId = dockerManager.runContainer(container, containerName, null, volumes, binds, "host", envs, null,
|
||||
536870912L, false);
|
||||
536870912L, false, null);
|
||||
containers.put(containerId, containerName);
|
||||
} catch (Exception e) {
|
||||
this.cleanRecordingMaps(recording);
|
||||
|
|
|
@ -20,11 +20,13 @@ package io.openvidu.server.utils;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ws.rs.ProcessingException;
|
||||
|
||||
import com.github.dockerjava.api.command.InspectContainerResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -104,7 +106,8 @@ public class DockerManager {
|
|||
}
|
||||
|
||||
public String runContainer(String container, String containerName, String user, List<Volume> volumes,
|
||||
List<Bind> binds, String networkMode, List<String> envs, List<String> command, Long shmSize, boolean privileged)
|
||||
List<Bind> binds, String networkMode, List<String> envs, List<String> command, Long shmSize, boolean privileged,
|
||||
Map<String, String> labels)
|
||||
throws Exception {
|
||||
|
||||
CreateContainerCmd cmd = dockerClient.createContainerCmd(container).withEnv(envs);
|
||||
|
@ -127,6 +130,10 @@ public class DockerManager {
|
|||
hostConfig.withBinds(binds);
|
||||
}
|
||||
|
||||
if (labels != null) {
|
||||
cmd.withLabels(labels);
|
||||
}
|
||||
|
||||
if (command != null) {
|
||||
cmd.withCmd(command);
|
||||
}
|
||||
|
@ -217,6 +224,11 @@ public class DockerManager {
|
|||
return containerIds;
|
||||
}
|
||||
|
||||
public Map<String, String> getLabels(String containerId) {
|
||||
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(containerId).exec();
|
||||
return containerInfo.getConfig().getLabels();
|
||||
}
|
||||
|
||||
static public String getDockerGatewayIp() {
|
||||
try {
|
||||
return CommandExecutor.execCommand(5000, "/bin/sh", "-c",
|
||||
|
|
Loading…
Reference in New Issue