docker/ts/docker.classes.container.ts

78 lines
1.8 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
*/
2019-08-14 12:19:45 +00:00
public 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-08-14 12:19:45 +00:00
// TODO: Think about getting the config by inpsecting the container
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
/**
2019-08-14 12:19:45 +00:00
* gets an container by Id
2019-01-09 23:24:35 +00:00
* @param containerId
*/
2019-08-14 12:19:45 +00:00
public static async getContainerById(containerId: string) {}
/**
* create a container
*/
2019-08-14 18:56:57 +00:00
public static async create(creationSpecifier: interfaces.IContainerCreationSpecifier) {}
2019-01-09 23:24:35 +00:00
// ========
// INSTANCE
// ========
constructor(dockerContainerObjectArg: any) {
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
this[keyArg] = dockerContainerObjectArg[keyArg];
2019-01-09 23:28:12 +00:00
});
2019-01-09 23:24:35 +00:00
}
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
}