in containers-docker-local/src/main/java/org/apache/aries/containers/docker/local/impl/LocalDockerServiceManager.java [248:279]
public Set<String> listServices() throws Exception {
Set<String> res = new HashSet<>();
List<String> ids = docker.ps(SERVICE_NAME_LABEL);
for (Service svc : services.values()) {
res.add(svc.getConfiguration().getServiceName());
for (Container c : svc.listContainers()) {
ids.remove(c.getID());
}
}
String json = docker.inspect(ids);
for (Object data : new JSONParser(json).getParsedList()) {
// These are services that have been launched previously and are not internally synced yet
if (!(data instanceof Map)) {
continue;
}
Object cd = ((Map) data).get("Config");
if (cd instanceof Map) {
Object ld = ((Map) cd).get("Labels");
if (ld instanceof Map) {
Object serviceName = ((Map) ld).get(SERVICE_NAME_LABEL);
if (serviceName instanceof String) {
res.add((String) serviceName);
}
}
}
}
return res;
}