How to use the systeminformation.dockerContainers function in systeminformation

To help you get started, we’ve selected a few systeminformation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / caliper / packages / caliper-core / lib / master / monitor / monitor-docker.js View on Github external
} else if (filterName.remote.hasOwnProperty(remote.hostname)) {
                        filterName.remote[remote.hostname].containers.push(remote.pathname);
                    } else {
                        filterName.remote[remote.hostname] = { port: remote.port, containers: [remote.pathname] };
                    }
                } else {
                    // Is local
                    filterName.local.push(container);
                }
            }
        }

        // Filter local containers by name
        if (filterName.local.length > 0) {
            try {
                const containers = await SystemInformation.dockerContainers('active');
                let size = containers.length;
                if (size === 0) {
                    Logger.error('Could not find any active local containers');
                } else {
                    if (filterName.local.indexOf('all') !== -1) {
                        // Add all containers
                        for (let i = 0; i < size; i++) {
                            this.containers.push({ id: containers[i].id, name: containers[i].name, remote: null });
                            this.stats[containers[i].id] = this.newContainerStat();
                        }
                    } else {
                        // Filter containers
                        for (let i = 0; i < size; i++) {
                            if (filterName.local.indexOf(containers[i].name) !== -1) {
                                this.containers.push({ id: containers[i].id, name: containers[i].name, remote: null });
                                this.stats[containers[i].id] = this.newContainerStat();