mirror of https://github.com/docker/docker-py.git
Added some type and version checks; removed security_opt from container_config (as this is invalid)
This commit is contained in:
parent
24b0cab2dc
commit
1845d3b13f
|
|
@ -444,7 +444,7 @@ class Client(requests.Session):
|
|||
network_disabled=False, name=None, entrypoint=None,
|
||||
cpu_shares=None, working_dir=None, domainname=None,
|
||||
memswap_limit=0, cpuset=None, host_config=None,
|
||||
mac_address=None, labels=None, security_opt=None):
|
||||
mac_address=None, labels=None):
|
||||
|
||||
if isinstance(volumes, six.string_types):
|
||||
volumes = [volumes, ]
|
||||
|
|
@ -458,8 +458,7 @@ class Client(requests.Session):
|
|||
self._version, image, command, hostname, user, detach, stdin_open,
|
||||
tty, mem_limit, ports, environment, dns, volumes, volumes_from,
|
||||
network_disabled, entrypoint, cpu_shares, working_dir, domainname,
|
||||
memswap_limit, cpuset, host_config, mac_address, labels,
|
||||
security_opt
|
||||
memswap_limit, cpuset, host_config, mac_address, labels
|
||||
)
|
||||
return self.create_container_from_config(config, name)
|
||||
|
||||
|
|
@ -883,6 +882,12 @@ class Client(requests.Session):
|
|||
'volumes_from is only supported for API version >= 1.10'
|
||||
)
|
||||
|
||||
if utils.compare_version('1.15', self._version) < 0:
|
||||
if security_opt is not None:
|
||||
raise errors.InvalidVersion(
|
||||
'security_opt is only supported for API version >= 1.15'
|
||||
)
|
||||
|
||||
if utils.compare_version('1.17', self._version) < 0:
|
||||
if read_only is not None:
|
||||
raise errors.InvalidVersion(
|
||||
|
|
|
|||
|
|
@ -395,6 +395,11 @@ def create_host_config(
|
|||
host_config['Dns'] = dns
|
||||
|
||||
if security_opt is not None:
|
||||
if not isinstance(security_opt, list):
|
||||
raise errors.DockerException(
|
||||
'Invalid type for security_opt param: expected list but found'
|
||||
' {0}'.format(type(security_opt))
|
||||
)
|
||||
host_config['SecurityOpt'] = security_opt
|
||||
|
||||
if volumes_from is not None:
|
||||
|
|
@ -447,7 +452,7 @@ def create_container_config(
|
|||
dns=None, volumes=None, volumes_from=None, network_disabled=False,
|
||||
entrypoint=None, cpu_shares=None, working_dir=None, domainname=None,
|
||||
memswap_limit=0, cpuset=None, host_config=None, mac_address=None,
|
||||
labels=None, security_opt=None
|
||||
labels=None
|
||||
):
|
||||
if isinstance(command, six.string_types):
|
||||
command = shlex.split(str(command))
|
||||
|
|
@ -546,5 +551,4 @@ def create_container_config(
|
|||
'HostConfig': host_config,
|
||||
'MacAddress': mac_address,
|
||||
'Labels': labels,
|
||||
'SecurityOpt': security_opt,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue