mirror of https://github.com/docker/docker-py.git
Adding units specification to mem_limit variable
This commit is contained in:
parent
14f9c07b01
commit
019468dad8
|
|
@ -81,6 +81,8 @@ more information on how to create port bindings and volume mappings.
|
||||||
The `environment` variable accepts a dictionary or a list of strings
|
The `environment` variable accepts a dictionary or a list of strings
|
||||||
in the following format `["PASSWORD=xxx"]` or `{"PASSWORD": "xxx"}`.
|
in the following format `["PASSWORD=xxx"]` or `{"PASSWORD": "xxx"}`.
|
||||||
|
|
||||||
|
The `mem_limit` variable accepts float values (which represent the memory limit of the created container in bytes) or a string with a units identification char ('1000k', 128m', '1g').
|
||||||
|
|
||||||
`volumes_from` and `dns` arguments raise TypeError exception if they are used
|
`volumes_from` and `dns` arguments raise TypeError exception if they are used
|
||||||
against v1.10 of docker remote API. Those arguments should be passed to
|
against v1.10 of docker remote API. Those arguments should be passed to
|
||||||
`start()` instead.
|
`start()` instead.
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,14 @@ class Client(requests.Session):
|
||||||
'{0}={1}'.format(k, v) for k, v in environment.items()
|
'{0}={1}'.format(k, v) for k, v in environment.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if isinstance(mem_limit, six.string_types):
|
||||||
|
units = {'k': 1024,
|
||||||
|
'm': 1024*1024,
|
||||||
|
'g': 1024*1024*1024}
|
||||||
|
suffix = mem_limit[-1].lower()
|
||||||
|
if suffix in units.keys():
|
||||||
|
mem_limit = int(mem_limit[:-1]) * units[suffix]
|
||||||
|
|
||||||
if isinstance(ports, list):
|
if isinstance(ports, list):
|
||||||
exposed_ports = {}
|
exposed_ports = {}
|
||||||
for port_definition in ports:
|
for port_definition in ports:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue