@@ -997,26 +997,25 @@ def restart(self, container, timeout=10):
997997 self ._raise_for_status (res )
998998
999999 @utils .check_resource
1000- def start (self , container , binds = None , port_bindings = None , lxc_conf = None ,
1001- publish_all_ports = None , links = None , privileged = None ,
1002- dns = None , dns_search = None , volumes_from = None , network_mode = None ,
1003- restart_policy = None , cap_add = None , cap_drop = None , devices = None ,
1004- extra_hosts = None , read_only = None , pid_mode = None , ipc_mode = None ,
1005- security_opt = None , ulimits = None ):
1000+ def start (self , container , * args , ** kwargs ):
10061001 """
10071002 Start a container. Similar to the ``docker start`` command, but
10081003 doesn't support attach options.
10091004
1010- **Deprecation warning:** For API version > 1.15, it is highly
1011- recommended to provide host config options in the ``host_config``
1012- parameter of :py:meth:`~ContainerApiMixin.create_container`.
1005+ **Deprecation warning:** Passing configuration options in ``start`` is
1006+ no longer supported. Users are expected to provide host config options
1007+ in the ``host_config`` parameter of
1008+ :py:meth:`~ContainerApiMixin.create_container`.
1009+
10131010
10141011 Args:
10151012 container (str): The container to start
10161013
10171014 Raises:
10181015 :py:class:`docker.errors.APIError`
10191016 If the server returns an error.
1017+ :py:class:`docker.errors.DeprecatedMethod`
1018+ If any argument besides ``container`` are provided.
10201019
10211020 Example:
10221021
@@ -1025,64 +1024,14 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
10251024 ... command='/bin/sleep 30')
10261025 >>> cli.start(container=container.get('Id'))
10271026 """
1028- if utils .compare_version ('1.10' , self ._version ) < 0 :
1029- if dns is not None :
1030- raise errors .InvalidVersion (
1031- 'dns is only supported for API version >= 1.10'
1032- )
1033- if volumes_from is not None :
1034- raise errors .InvalidVersion (
1035- 'volumes_from is only supported for API version >= 1.10'
1036- )
1037-
1038- if utils .compare_version ('1.15' , self ._version ) < 0 :
1039- if security_opt is not None :
1040- raise errors .InvalidVersion (
1041- 'security_opt is only supported for API version >= 1.15'
1042- )
1043- if ipc_mode :
1044- raise errors .InvalidVersion (
1045- 'ipc_mode is only supported for API version >= 1.15'
1046- )
1047-
1048- if utils .compare_version ('1.17' , self ._version ) < 0 :
1049- if read_only is not None :
1050- raise errors .InvalidVersion (
1051- 'read_only is only supported for API version >= 1.17'
1052- )
1053- if pid_mode is not None :
1054- raise errors .InvalidVersion (
1055- 'pid_mode is only supported for API version >= 1.17'
1056- )
1057-
1058- if utils .compare_version ('1.18' , self ._version ) < 0 :
1059- if ulimits is not None :
1060- raise errors .InvalidVersion (
1061- 'ulimits is only supported for API version >= 1.18'
1062- )
1063-
1064- start_config_kwargs = dict (
1065- binds = binds , port_bindings = port_bindings , lxc_conf = lxc_conf ,
1066- publish_all_ports = publish_all_ports , links = links , dns = dns ,
1067- privileged = privileged , dns_search = dns_search , cap_add = cap_add ,
1068- cap_drop = cap_drop , volumes_from = volumes_from , devices = devices ,
1069- network_mode = network_mode , restart_policy = restart_policy ,
1070- extra_hosts = extra_hosts , read_only = read_only , pid_mode = pid_mode ,
1071- ipc_mode = ipc_mode , security_opt = security_opt , ulimits = ulimits ,
1072- )
1073- start_config = None
1074-
1075- if any (v is not None for v in start_config_kwargs .values ()):
1076- if utils .compare_version ('1.15' , self ._version ) > 0 :
1077- warnings .warn (
1078- 'Passing host config parameters in start() is deprecated. '
1079- 'Please use host_config in create_container instead!' ,
1080- DeprecationWarning
1081- )
1082- start_config = self .create_host_config (** start_config_kwargs )
1083-
1027+ if args or kwargs :
1028+ raise errors .DeprecatedMethod (
1029+ 'Providing configuration in the start() method is no longer '
1030+ 'supported. Use the host_config param in create_container '
1031+ 'instead.'
1032+ )
10841033 url = self ._url ("/containers/{0}/start" , container )
1085- res = self ._post_json (url , data = start_config )
1034+ res = self ._post (url )
10861035 self ._raise_for_status (res )
10871036
10881037 @utils .minimum_version ('1.17' )
0 commit comments