implement .createContainer()

This commit is contained in:
Philipp Kunz 2016-06-17 02:38:00 +02:00
parent c356042075
commit 4da7f5194a
3 changed files with 62 additions and 13 deletions

View File

@ -10,13 +10,13 @@ export declare class Dockersock {
listImages(): any; listImages(): any;
listImagesDangling(): any; listImagesDangling(): any;
pullImage(imageLabel: string): any; pullImage(imageLabel: string): any;
createContainer(imageNameArg: any, pullFirst?: boolean): any; createContainer(optionsArg: any, pullFirstArg?: boolean): any;
getContainerId(): void; getContainerId(): void;
startContainer(containerNameArg: any): any; startContainer(containerNameArg: any): any;
stopContainer(containerNameArg: any): any; stopContainer(containerNameArg: any): any;
removeContainer(containerNameArg: any): any; removeContainer(containerNameArg: any): any;
clean(): any; clean(): any;
getChange(): void; callOnChange(cb: Function): void;
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any; request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): any;
requestStream(methodArg: any, routeArg: any, endArg?: boolean): any; requestStream(methodArg: any, routeArg: any, endArg?: boolean): any;
} }

File diff suppressed because one or more lines are too long

View File

@ -59,10 +59,20 @@ export class Dockersock {
pullImage(imageLabel:string){ pullImage(imageLabel:string){
return this.requestStream("POST","/images/create?fromImage=" + imageLabel); return this.requestStream("POST","/images/create?fromImage=" + imageLabel);
}; };
createContainer(imageNameArg,pullFirst:boolean = true){ createContainer(optionsArg,pullFirstArg:boolean = true){
return this.request("POST","/containers/create","",{ let done = plugins.q.defer();
"image":imageNameArg let create = () => {
}); return this.request("POST","/containers/create","",optionsArg);
}
if(pullFirstArg){
this.pullImage(optionsArg.Image)
.then(create)
.then(done.resolve);
} else {
create()
.then(done.resolve)
}
return done.promise;
}; };
getContainerId(){ getContainerId(){