@@ -204,15 +204,13 @@ def containers(self, quiet=False, all=False, trunc=False, latest=False,
204
204
return res
205
205
206
206
def create_container (self , image , command = None , hostname = None , user = None ,
207
- detach = False , stdin_open = False , tty = False ,
208
- mem_limit = None , ports = None , environment = None ,
209
- dns = None , volumes = None , volumes_from = None ,
207
+ detach = False , stdin_open = False , tty = False , ports = None ,
208
+ environment = None , volumes = None ,
210
209
network_disabled = False , name = None , entrypoint = None ,
211
- cpu_shares = None , working_dir = None , domainname = None ,
212
- memswap_limit = None , cpuset = None , host_config = None ,
213
- mac_address = None , labels = None , volume_driver = None ,
214
- stop_signal = None , networking_config = None ,
215
- healthcheck = None , stop_timeout = None , runtime = None ):
210
+ working_dir = None , domainname = None , host_config = None ,
211
+ mac_address = None , labels = None , stop_signal = None ,
212
+ networking_config = None , healthcheck = None ,
213
+ stop_timeout = None , runtime = None ):
216
214
"""
217
215
Creates a container. Parameters are similar to those for the ``docker
218
216
run`` command except it doesn't support the attach options (``-a``).
@@ -354,35 +352,24 @@ def create_container(self, image, command=None, hostname=None, user=None,
354
352
return container ID
355
353
stdin_open (bool): Keep STDIN open even if not attached
356
354
tty (bool): Allocate a pseudo-TTY
357
- mem_limit (float or str): Memory limit. Accepts float values (which
358
- represent the memory limit of the created container in bytes)
359
- or a string with a units identification char (``100000b``,
360
- ``1000k``, ``128m``, ``1g``). If a string is specified without
361
- a units character, bytes are assumed as an intended unit.
362
355
ports (list of ints): A list of port numbers
363
356
environment (dict or list): A dictionary or a list of strings in
364
357
the following format ``["PASSWORD=xxx"]`` or
365
358
``{"PASSWORD": "xxx"}``.
366
- dns (:py:class:`list`): DNS name servers. Deprecated since API
367
- version 1.10. Use ``host_config`` instead.
368
359
volumes (str or list): List of paths inside the container to use
369
360
as volumes.
370
- volumes_from (:py:class:`list`): List of container names or Ids to
371
- get volumes from.
372
361
network_disabled (bool): Disable networking
373
362
name (str): A name for the container
374
363
entrypoint (str or list): An entrypoint
375
364
working_dir (str): Path to the working directory
376
365
domainname (str): The domain name to use for the container
377
- memswap_limit (int):
378
366
host_config (dict): A dictionary created with
379
367
:py:meth:`create_host_config`.
380
368
mac_address (str): The Mac Address to assign the container
381
369
labels (dict or list): A dictionary of name-value labels (e.g.
382
370
``{"label1": "value1", "label2": "value2"}``) or a list of
383
371
names of labels to set with empty values (e.g.
384
372
``["label1", "label2"]``)
385
- volume_driver (str): The name of a volume driver/plugin.
386
373
stop_signal (str): The stop signal to use to stop the container
387
374
(e.g. ``SIGINT``).
388
375
stop_timeout (int): Timeout to stop the container, in seconds.
@@ -405,17 +392,12 @@ def create_container(self, image, command=None, hostname=None, user=None,
405
392
if isinstance (volumes , six .string_types ):
406
393
volumes = [volumes , ]
407
394
408
- if host_config and utils .compare_version ('1.15' , self ._version ) < 0 :
409
- raise errors .InvalidVersion (
410
- 'host_config is not supported in API < 1.15'
411
- )
412
-
413
395
config = self .create_container_config (
414
- image , command , hostname , user , detach , stdin_open , tty , mem_limit ,
415
- ports , dns , environment , volumes , volumes_from ,
416
- network_disabled , entrypoint , cpu_shares , working_dir , domainname ,
417
- memswap_limit , cpuset , host_config , mac_address , labels ,
418
- volume_driver , stop_signal , networking_config , healthcheck ,
396
+ image , command , hostname , user , detach , stdin_open , tty ,
397
+ ports , environment , volumes ,
398
+ network_disabled , entrypoint , working_dir , domainname ,
399
+ host_config , mac_address , labels ,
400
+ stop_signal , networking_config , healthcheck ,
419
401
stop_timeout , runtime
420
402
)
421
403
return self .create_container_from_config (config , name )
@@ -681,7 +663,6 @@ def export(self, container):
681
663
return self ._stream_raw_result (res )
682
664
683
665
@utils .check_resource ('container' )
684
- @utils .minimum_version ('1.20' )
685
666
def get_archive (self , container , path ):
686
667
"""
687
668
Retrieve a file or folder from a container in the form of a tar
@@ -786,59 +767,46 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
786
767
:py:class:`docker.errors.APIError`
787
768
If the server returns an error.
788
769
"""
789
- if utils .compare_version ('1.11' , self ._version ) >= 0 :
790
- if follow is None :
791
- follow = stream
792
- params = {'stderr' : stderr and 1 or 0 ,
793
- 'stdout' : stdout and 1 or 0 ,
794
- 'timestamps' : timestamps and 1 or 0 ,
795
- 'follow' : follow and 1 or 0 ,
796
- }
797
- if utils .compare_version ('1.13' , self ._version ) >= 0 :
798
- if tail != 'all' and (not isinstance (tail , int ) or tail < 0 ):
799
- tail = 'all'
800
- params ['tail' ] = tail
801
-
802
- if since is not None :
803
- if utils .version_lt (self ._version , '1.19' ):
804
- raise errors .InvalidVersion (
805
- 'since is not supported for API version < 1.19'
806
- )
807
- if isinstance (since , datetime ):
808
- params ['since' ] = utils .datetime_to_timestamp (since )
809
- elif (isinstance (since , int ) and since > 0 ):
810
- params ['since' ] = since
811
- else :
812
- raise errors .InvalidArgument (
813
- 'since value should be datetime or positive int, '
814
- 'not {}' .format (type (since ))
815
- )
816
-
817
- if until is not None :
818
- if utils .version_lt (self ._version , '1.35' ):
819
- raise errors .InvalidVersion (
820
- 'until is not supported for API version < 1.35'
821
- )
822
- if isinstance (until , datetime ):
823
- params ['until' ] = utils .datetime_to_timestamp (until )
824
- elif (isinstance (until , int ) and until > 0 ):
825
- params ['until' ] = until
826
- else :
827
- raise errors .InvalidArgument (
828
- 'until value should be datetime or positive int, '
829
- 'not {}' .format (type (until ))
830
- )
831
-
832
- url = self ._url ("/containers/{0}/logs" , container )
833
- res = self ._get (url , params = params , stream = stream )
834
- return self ._get_result (container , stream , res )
835
- return self .attach (
836
- container ,
837
- stdout = stdout ,
838
- stderr = stderr ,
839
- stream = stream ,
840
- logs = True
841
- )
770
+ if follow is None :
771
+ follow = stream
772
+ params = {'stderr' : stderr and 1 or 0 ,
773
+ 'stdout' : stdout and 1 or 0 ,
774
+ 'timestamps' : timestamps and 1 or 0 ,
775
+ 'follow' : follow and 1 or 0 ,
776
+ }
777
+ if tail != 'all' and (not isinstance (tail , int ) or tail < 0 ):
778
+ tail = 'all'
779
+ params ['tail' ] = tail
780
+
781
+ if since is not None :
782
+ if isinstance (since , datetime ):
783
+ params ['since' ] = utils .datetime_to_timestamp (since )
784
+ elif (isinstance (since , int ) and since > 0 ):
785
+ params ['since' ] = since
786
+ else :
787
+ raise errors .InvalidArgument (
788
+ 'since value should be datetime or positive int, '
789
+ 'not {}' .format (type (since ))
790
+ )
791
+
792
+ if until is not None :
793
+ if utils .version_lt (self ._version , '1.35' ):
794
+ raise errors .InvalidVersion (
795
+ 'until is not supported for API version < 1.35'
796
+ )
797
+ if isinstance (until , datetime ):
798
+ params ['until' ] = utils .datetime_to_timestamp (until )
799
+ elif (isinstance (until , int ) and until > 0 ):
800
+ params ['until' ] = until
801
+ else :
802
+ raise errors .InvalidArgument (
803
+ 'until value should be datetime or positive int, '
804
+ 'not {}' .format (type (until ))
805
+ )
806
+
807
+ url = self ._url ("/containers/{0}/logs" , container )
808
+ res = self ._get (url , params = params , stream = stream )
809
+ return self ._get_result (container , stream , res )
842
810
843
811
@utils .check_resource ('container' )
844
812
def pause (self , container ):
@@ -906,7 +874,6 @@ def port(self, container, private_port):
906
874
return h_ports
907
875
908
876
@utils .check_resource ('container' )
909
- @utils .minimum_version ('1.20' )
910
877
def put_archive (self , container , path , data ):
911
878
"""
912
879
Insert a file or folder in an existing container using a tar archive as
@@ -976,7 +943,6 @@ def remove_container(self, container, v=False, link=False, force=False):
976
943
)
977
944
self ._raise_for_status (res )
978
945
979
- @utils .minimum_version ('1.17' )
980
946
@utils .check_resource ('container' )
981
947
def rename (self , container , name ):
982
948
"""
@@ -1073,7 +1039,6 @@ def start(self, container, *args, **kwargs):
1073
1039
res = self ._post (url )
1074
1040
self ._raise_for_status (res )
1075
1041
1076
- @utils .minimum_version ('1.17' )
1077
1042
@utils .check_resource ('container' )
1078
1043
def stats (self , container , decode = None , stream = True ):
1079
1044
"""
0 commit comments