@@ -9,19 +9,21 @@ use crate::{
99 } ,
1010} ;
1111use base64:: { engine:: general_purpose, Engine as _} ;
12- use bollard :: container :: LogOutput :: Console ;
12+
1313use bollard:: {
14- container:: {
15- Config , CreateContainerOptions , InspectContainerOptions , KillContainerOptions ,
14+ container:: LogOutput :: Console ,
15+ errors:: Error ,
16+ models:: {
17+ ContainerCreateBody , ContainerInspectResponse , ContainerState , ContainerStateStatusEnum ,
18+ ContainerSummary , EndpointSettings , HostConfig , Mount , NetworkConnectRequest , PortBinding ,
19+ } ,
20+ query_parameters:: {
21+ CreateContainerOptions , InspectContainerOptions , KillContainerOptions ,
1622 ListContainersOptions , LogsOptions , RemoveContainerOptions , StartContainerOptions ,
1723 StopContainerOptions , WaitContainerOptions ,
1824 } ,
19- errors:: Error ,
20- models:: { ContainerState , HostConfig } ,
21- network:: ConnectNetworkOptions ,
22- secret:: { ContainerStateStatusEnum , Mount } ,
23- service:: { ContainerInspectResponse , ContainerSummary , EndpointSettings , PortBinding } ,
2425} ;
26+
2527use futures:: { future, StreamExt } ;
2628use std:: {
2729 collections:: HashMap ,
@@ -52,7 +54,7 @@ pub fn inject(script: &str, name: &str) -> Vec<String> {
5254impl < ' a > ContainerApi < ' a > {
5355 pub async fn get_all ( & self , labels : & Labels ) -> Result < Vec < ContainerSummary > , AnyError > {
5456 let list_options = ListContainersOptions {
55- filters : labels. into ( ) ,
57+ filters : Some ( labels. into ( ) ) ,
5658 all : true ,
5759 ..Default :: default ( )
5860 } ;
@@ -62,7 +64,7 @@ impl<'a> ContainerApi<'a> {
6264
6365 pub async fn get_running ( & self , labels : & Labels ) -> Result < Vec < ContainerSummary > , AnyError > {
6466 let list_options = ListContainersOptions {
65- filters : labels. into ( ) ,
67+ filters : Some ( labels. into ( ) ) ,
6668 all : false ,
6769 ..Default :: default ( )
6870 } ;
@@ -150,7 +152,7 @@ impl<'a> ContainerApi<'a> {
150152 pub async fn kill ( & self , container_id : & str , wait_for_remove : bool ) -> Result < ( ) , AnyError > {
151153 match self
152154 . client
153- . kill_container ( & container_id, None :: < KillContainerOptions < String > > )
155+ . kill_container ( & container_id, None :: < KillContainerOptions > )
154156 . await
155157 {
156158 Ok ( _) => {
@@ -207,12 +209,21 @@ impl<'a> ContainerApi<'a> {
207209
208210 pub async fn stop ( & self , container_id : & str ) -> Result < ( ) , AnyError > {
209211 self . client
210- . stop_container ( & container_id, Some ( StopContainerOptions { t : 0 } ) )
212+ . stop_container (
213+ & container_id,
214+ Some ( StopContainerOptions {
215+ t : Some ( 0 ) ,
216+ signal : Some ( "SIGINT" . into ( ) ) ,
217+ } ) ,
218+ )
211219 . await ?;
212220 let mut count = 10 ;
213221 while count > 0 {
214222 log:: debug!( "Waiting for container {} to be gone..." , container_id) ;
215- let r = self . client . inspect_container ( & container_id, None ) . await ;
223+ let r = self
224+ . client
225+ . inspect_container ( & container_id, None :: < InspectContainerOptions > )
226+ . await ;
216227 if let Err ( Error :: DockerResponseServerError {
217228 status_code : 404 , ..
218229 } ) = r
@@ -241,7 +252,7 @@ impl<'a> ContainerApi<'a> {
241252
242253 let container_id = match self
243254 . client
244- . inspect_container ( & spec. container_name , None )
255+ . inspect_container ( & spec. container_name , None :: < InspectContainerOptions > )
245256 . await
246257 {
247258 Ok ( ContainerInspectResponse { id : Some ( id) , .. } ) if !spec. force_recreate => {
@@ -260,8 +271,8 @@ impl<'a> ContainerApi<'a> {
260271 }
261272
262273 let options = CreateContainerOptions {
263- name : spec. container_name ,
264- platform : None ,
274+ name : Some ( spec. container_name . to_string ( ) ) ,
275+ platform : "linux/amd64" . into ( ) ,
265276 } ;
266277
267278 let oom_score_adj = match self . backend {
@@ -321,21 +332,25 @@ impl<'a> ContainerApi<'a> {
321332
322333 let env = KeyValue :: to_vec_str ( & env_kv) ;
323334
324- let config = Config {
325- image : Some ( spec. image ) ,
326- entrypoint : spec. entrypoint ,
327- cmd : spec. command ,
328- working_dir : spec. work_dir ,
335+ let config = ContainerCreateBody {
336+ image : Some ( spec. image . to_string ( ) ) ,
337+ entrypoint : spec
338+ . entrypoint
339+ . map ( |vec| vec. iter ( ) . map ( |& s| s. to_string ( ) ) . collect ( ) ) ,
340+ cmd : spec
341+ . command
342+ . map ( |vec| vec. iter ( ) . map ( |& s| s. to_string ( ) ) . collect ( ) ) ,
343+ working_dir : spec. work_dir . map ( |s| s. to_string ( ) ) ,
329344 // THIS MUST BE spec.uid, NOT spec.user - otherwise file ownership will break
330- user : Some ( spec. uid ) ,
345+ user : Some ( spec. uid . to_string ( ) ) ,
331346 attach_stdin,
332347 attach_stdout : Some ( true ) ,
333348 attach_stderr : Some ( true ) ,
334349 tty,
335350 open_stdin,
336351 host_config : Some ( host_config) ,
337352 labels : Some ( ( & spec. labels ) . into ( ) ) ,
338- env : Some ( env) ,
353+ env : Some ( env. iter ( ) . map ( | & s| s . to_string ( ) ) . collect ( ) ) ,
339354 ..Default :: default ( )
340355 } ;
341356
@@ -345,12 +360,12 @@ impl<'a> ContainerApi<'a> {
345360 . await ?;
346361
347362 if let Some ( network) = & spec. network {
348- let connect_network_options = ConnectNetworkOptions {
349- container : & response. id ,
350- endpoint_config : EndpointSettings {
363+ let connect_network_options = NetworkConnectRequest {
364+ container : Some ( response. id . to_string ( ) ) ,
365+ endpoint_config : Some ( EndpointSettings {
351366 aliases : spec. network_aliases ,
352367 ..Default :: default ( )
353- } ,
368+ } ) ,
354369 } ;
355370 self . client
356371 . connect_network ( network, connect_network_options)
@@ -359,7 +374,7 @@ impl<'a> ContainerApi<'a> {
359374 log:: debug!(
360375 "Created container: {} ({})" ,
361376 spec. container_name,
362- response. id
377+ response. id. to_string ( )
363378 ) ;
364379
365380 ContainerResult :: Created { id : response. id }
@@ -371,7 +386,7 @@ impl<'a> ContainerApi<'a> {
371386 pub async fn start ( & self , container_id : & str ) -> Result < ( ) , AnyError > {
372387 match self
373388 . client
374- . start_container ( & container_id, None :: < StartContainerOptions < String > > )
389+ . start_container ( & container_id, None :: < StartContainerOptions > )
375390 . await
376391 . map_err ( |e| Box :: new ( e) )
377392 {
@@ -421,7 +436,7 @@ impl<'a> ContainerApi<'a> {
421436 let log_task = tokio:: spawn ( async move {
422437 let logs_stream = docker_logs. logs (
423438 & s_id,
424- Some ( LogsOptions :: < String > {
439+ Some ( LogsOptions {
425440 follow : true ,
426441 stdout : true ,
427442 stderr : true ,
@@ -445,7 +460,7 @@ impl<'a> ContainerApi<'a> {
445460
446461 let mut exit_code_stream = self
447462 . client
448- . wait_container ( & id, None :: < WaitContainerOptions < String > > ) ;
463+ . wait_container ( & id, None :: < WaitContainerOptions > ) ;
449464
450465 let _ = match exit_code_stream. next ( ) . await {
451466 Some ( Ok ( response) ) => response. status_code ,
@@ -475,7 +490,7 @@ impl<'a> ContainerApi<'a> {
475490 let log_task = tokio:: spawn ( async move {
476491 let logs_stream = docker_logs. logs (
477492 & s_id,
478- Some ( LogsOptions :: < String > {
493+ Some ( LogsOptions {
479494 follow : true ,
480495 stdout : true ,
481496 stderr : true ,
@@ -502,7 +517,7 @@ impl<'a> ContainerApi<'a> {
502517
503518 let mut exit_code_stream = self
504519 . client
505- . wait_container ( & id, None :: < WaitContainerOptions < String > > ) ;
520+ . wait_container ( & id, None :: < WaitContainerOptions > ) ;
506521
507522 let exit_code = match exit_code_stream. next ( ) . await {
508523 Some ( Ok ( response) ) => response. status_code ,
@@ -515,7 +530,7 @@ impl<'a> ContainerApi<'a> {
515530 }
516531
517532 pub async fn logs_to_stdout ( & self , container_name : & str ) -> Result < ( ) , AnyError > {
518- let log_options = LogsOptions :: < String > {
533+ let log_options = LogsOptions {
519534 stdout : true ,
520535 follow : true ,
521536 ..Default :: default ( )
0 commit comments