File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ pub enum ClientError {
7777 StartContainer ( BollardError ) ,
7878 #[ error( "failed to stop a container: {0}" ) ]
7979 StopContainer ( BollardError ) ,
80+ #[ error( "failed to pause a container: {0}" ) ]
81+ PauseContainer ( BollardError ) ,
82+ #[ error( "failed to unpause/resume a container: {0}" ) ]
83+ UnpauseContainer ( BollardError ) ,
8084 #[ error( "failed to inspect a container: {0}" ) ]
8185 InspectContainer ( BollardError ) ,
8286
@@ -183,6 +187,20 @@ impl Client {
183187 . map_err ( ClientError :: Init )
184188 }
185189
190+ pub ( crate ) async fn pause ( & self , id : & str ) -> Result < ( ) , ClientError > {
191+ self . bollard
192+ . pause_container ( id)
193+ . await
194+ . map_err ( ClientError :: PauseContainer )
195+ }
196+
197+ pub ( crate ) async fn unpause ( & self , id : & str ) -> Result < ( ) , ClientError > {
198+ self . bollard
199+ . unpause_container ( id)
200+ . await
201+ . map_err ( ClientError :: UnpauseContainer )
202+ }
203+
186204 pub ( crate ) async fn exec (
187205 & self ,
188206 container_id : & str ,
Original file line number Diff line number Diff line change @@ -304,6 +304,20 @@ where
304304 Ok ( ( ) )
305305 }
306306
307+ /// Pause the container.
308+ /// [Docker Engine API](https://docs.docker.com/reference/api/engine/version/v1.48/#tag/Container/operation/ContainerPause)
309+ pub async fn pause ( & self ) -> Result < ( ) > {
310+ self . docker_client . pause ( & self . id ) . await ?;
311+ Ok ( ( ) )
312+ }
313+
314+ /// Resume/Unpause the container.
315+ /// [Docker Engine API](https://docs.docker.com/reference/api/engine/version/v1.48/#tag/Container/operation/ContainerUnpause)
316+ pub async fn unpause ( & self ) -> Result < ( ) > {
317+ self . docker_client . unpause ( & self . id ) . await ?;
318+ Ok ( ( ) )
319+ }
320+
307321 /// Removes the container.
308322 pub async fn rm ( mut self ) -> Result < ( ) > {
309323 log:: debug!( "Deleting docker container {}" , self . id) ;
Original file line number Diff line number Diff line change @@ -147,6 +147,18 @@ where
147147 self . rt ( ) . block_on ( self . async_impl ( ) . start ( ) )
148148 }
149149
150+ /// Pause the container.
151+ /// [Docker Engine API](https://docs.docker.com/reference/api/engine/version/v1.48/#tag/Container/operation/ContainerPause)
152+ pub async fn pause ( & self ) -> Result < ( ) > {
153+ self . rt ( ) . block_on ( self . async_impl ( ) . pause ( ) )
154+ }
155+
156+ /// Resume/Unpause the container.
157+ /// [Docker Engine API](https://docs.docker.com/reference/api/engine/version/v1.48/#tag/Container/operation/ContainerUnpause)
158+ pub async fn unpause ( & self ) -> Result < ( ) > {
159+ self . rt ( ) . block_on ( self . async_impl ( ) . unpause ( ) )
160+ }
161+
150162 /// Removes the container.
151163 pub fn rm ( mut self ) -> Result < ( ) > {
152164 if let Some ( active) = self . inner . take ( ) {
You can’t perform that action at this time.
0 commit comments