diff --git a/docker/client.py b/docker/client.py index befeb84c..987e2747 100644 --- a/docker/client.py +++ b/docker/client.py @@ -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( diff --git a/docker/utils/utils.py b/docker/utils/utils.py index af9a57b0..47c4c95d 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -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, }