@@ -223,7 +223,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
223
223
mac_address = None , labels = None , stop_signal = None ,
224
224
networking_config = None , healthcheck = None ,
225
225
stop_timeout = None , runtime = None ,
226
- use_config_proxy = True ):
226
+ use_config_proxy = True , platform = None ):
227
227
"""
228
228
Creates a container. Parameters are similar to those for the ``docker
229
229
run`` command except it doesn't support the attach options (``-a``).
@@ -398,6 +398,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
398
398
configuration file (``~/.docker/config.json`` by default)
399
399
contains a proxy configuration, the corresponding environment
400
400
variables will be set in the container being created.
401
+ platform (str): Platform in the format ``os[/arch[/variant]]``.
401
402
402
403
Returns:
403
404
A dictionary with an image 'Id' key and a 'Warnings' key.
@@ -427,16 +428,22 @@ def create_container(self, image, command=None, hostname=None, user=None,
427
428
stop_signal , networking_config , healthcheck ,
428
429
stop_timeout , runtime
429
430
)
430
- return self .create_container_from_config (config , name )
431
+ return self .create_container_from_config (config , name , platform )
431
432
432
433
def create_container_config (self , * args , ** kwargs ):
433
434
return ContainerConfig (self ._version , * args , ** kwargs )
434
435
435
- def create_container_from_config (self , config , name = None ):
436
+ def create_container_from_config (self , config , name = None , platform = None ):
436
437
u = self ._url ("/containers/create" )
437
438
params = {
438
439
'name' : name
439
440
}
441
+ if platform :
442
+ if utils .version_lt (self ._version , '1.41' ):
443
+ raise errors .InvalidVersion (
444
+ 'platform is not supported for API version < 1.41'
445
+ )
446
+ params ['platform' ] = platform
440
447
res = self ._post_json (u , data = config , params = params )
441
448
return self ._result (res , True )
442
449
0 commit comments