docker/ts/docker.classes.container.ts

74 lines
1.6 KiB
TypeScript
Raw Normal View History

2018-07-16 21:52:50 +00:00
import * as plugins from './dockersock.plugins';
2019-01-09 23:24:35 +00:00
import * as interfaces from './interfaces';
2018-07-16 21:52:50 +00:00
import { DockerHost } from './docker.classes.host';
export class DockerContainer {
2019-01-09 23:24:35 +00:00
// ======
// STATIC
// ======
/**
* get all containers
*/
2018-07-16 21:52:50 +00:00
static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
2018-07-17 06:39:37 +00:00
const result: DockerContainer[] = [];
const response = await dockerHostArg.request('GET', '/containers/json');
2019-01-09 23:24:35 +00:00
for (const containerResult of response.body) {
result.push(new DockerContainer(containerResult));
2018-07-17 06:39:37 +00:00
}
2018-07-16 21:52:50 +00:00
return result;
}
2019-01-09 23:24:35 +00:00
/**
*
* @param containerId
*/
static async getContainerById(containerId: string) {
}
static async create() {}
// ========
// INSTANCE
// ========
constructor(dockerContainerObjectArg: any) {
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
this[keyArg] = dockerContainerObjectArg[keyArg];
})
}
Id: string;
Names: string[];
Image: string;
ImageID: string;
Command: string;
Created: number;
Ports: interfaces.TPorts;
Labels: interfaces.TLabels;
State: string;
Status: string;
HostConfig: any;
NetworkSettings: {
Networks: {
[key: string]: {
IPAMConfig: any;
Links: any;
Aliases: any;
NetworkID: string;
EndpointID: string;
Gateway: string;
IPAddress: string;
IPPrefixLen: number;
IPv6Gateway: string;
GlobalIPv6Address: string;
GlobalIPv6PrefixLen: number;
MacAddress: string;
DriverOpts: any;
};
};
};
Mounts: any;
2018-07-16 21:52:50 +00:00
}