@@ -187,13 +187,27 @@ where
187187 None
188188 } ;
189189
190+ let mut options_builder: Option < CreateContainerOptionsBuilder > = None ;
191+
190192 // name of the container
191193 if let Some ( name) = container_req. container_name ( ) {
192- let options = CreateContainerOptionsBuilder :: new ( )
193- . name ( name)
194- . platform ( client. config . platform ( ) . unwrap_or_default ( ) )
195- . build ( ) ;
196- create_options = Some ( options)
194+ let options = CreateContainerOptionsBuilder :: new ( ) . name ( name) ;
195+
196+ options_builder = Some ( options) ;
197+ }
198+
199+ // platform of the container
200+ if let Some ( platform) = container_req. platform ( ) {
201+ let options = options_builder. unwrap_or ( CreateContainerOptionsBuilder :: new ( ) ) ;
202+ options_builder = Some ( options. platform ( platform) ) ;
203+ } else {
204+ // set platform from global platform setting if available
205+ let options = options_builder. unwrap_or ( CreateContainerOptionsBuilder :: new ( ) ) ;
206+ options_builder = Some ( options. platform ( client. config . platform ( ) . unwrap_or_default ( ) ) ) ;
207+ }
208+
209+ if let Some ( options) = options_builder {
210+ create_options = Some ( options. build ( ) ) ;
197211 }
198212
199213 // handle environment variables
@@ -311,7 +325,12 @@ where
311325 status_code : 404 , ..
312326 } ,
313327 ) ) => {
314- client. pull_image ( & container_req. descriptor ( ) ) . await ?;
328+ client
329+ . pull_image (
330+ & container_req. descriptor ( ) ,
331+ container_req. platform ( ) . clone ( ) ,
332+ )
333+ . await ?;
315334 client. create_container ( create_options, config) . await
316335 }
317336 res => res,
@@ -361,7 +380,12 @@ where
361380 async fn pull_image ( self ) -> Result < ContainerRequest < I > > {
362381 let container_req = self . into ( ) ;
363382 let client = Client :: lazy_client ( ) . await ?;
364- client. pull_image ( & container_req. descriptor ( ) ) . await ?;
383+ client
384+ . pull_image (
385+ & container_req. descriptor ( ) ,
386+ container_req. platform ( ) . clone ( ) ,
387+ )
388+ . await ?;
365389
366390 Ok ( container_req)
367391 }
0 commit comments