File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -193,14 +193,13 @@ export function killContainer(id: string): Promise<void> {
193193 container = docker . getContainer ( id ) ;
194194 container . inspect ( )
195195 . then ( containerInfo => {
196- if ( containerInfo . State . Status === 'exited' ) {
197- return container . remove ( ) ;
198- } else if ( containerInfo . State . Status === 'running' ) {
196+ if ( containerInfo . State . Status === 'running' ) {
199197 return container . kill ( ) ;
200198 } else {
201199 return Promise . resolve ( ) ;
202200 }
203201 } )
202+ . then ( ( ) => removeContainer ( id ) )
204203 . then ( ( ) => resolve ( ) )
205204 . catch ( err => {
206205 if ( err . statusCode === 404 ) {
@@ -216,7 +215,18 @@ export function killContainer(id: string): Promise<void> {
216215}
217216
218217export function removeContainer ( id : string ) : Promise < void > {
219- return docker . getContainer ( id ) . remove ( ) ;
218+ return new Promise ( resolve => {
219+ try {
220+ let container = docker . getContainer ( id ) ;
221+
222+ return container . inspect ( )
223+ . then ( containerInfo => container . remove ( ) )
224+ . then ( ( ) => resolve ( ) )
225+ . catch ( ( ) => resolve ( ) ) ;
226+ } catch {
227+ resolve ( ) ;
228+ }
229+ } ) ;
220230}
221231
222232export function imageExists ( name : string ) : Observable < boolean > {
You can’t perform that action at this time.
0 commit comments