@@ -7,8 +7,8 @@ use std::{
77use bollard:: {
88 auth:: DockerCredentials ,
99 container:: {
10- Config , CreateContainerOptions , ListContainersOptions , LogOutput , LogsOptions ,
11- RemoveContainerOptions , UploadToContainerOptions ,
10+ Config , CreateContainerOptions , InspectContainerOptions , ListContainersOptions , LogOutput ,
11+ LogsOptions , RemoveContainerOptions , UploadToContainerOptions ,
1212 } ,
1313 errors:: Error as BollardError ,
1414 exec:: { CreateExecOptions , StartExecOptions , StartExecResults } ,
@@ -340,6 +340,22 @@ impl Client {
340340 . map_err ( ClientError :: UploadToContainerError )
341341 }
342342
343+ pub ( crate ) async fn container_is_running (
344+ & self ,
345+ container_id : & str ,
346+ ) -> Result < bool , ClientError > {
347+ let container_info = self
348+ . bollard
349+ . inspect_container ( container_id, Some ( InspectContainerOptions { size : false } ) )
350+ . await
351+ . map_err ( ClientError :: InspectContainer ) ?;
352+ if let Some ( state) = container_info. state {
353+ Ok ( state. running . unwrap_or_default ( ) )
354+ } else {
355+ Ok ( false )
356+ }
357+ }
358+
343359 pub ( crate ) async fn pull_image ( & self , descriptor : & str ) -> Result < ( ) , ClientError > {
344360 let pull_options = Some ( CreateImageOptions {
345361 from_image : descriptor,
0 commit comments