@@ -112,7 +112,7 @@ def attach_socket(self, container, params=None, ws=False):
112
112
113
113
@utils .check_resource ('container' )
114
114
def commit (self , container , repository = None , tag = None , message = None ,
115
- author = None , changes = None , conf = None ):
115
+ author = None , pause = True , changes = None , conf = None ):
116
116
"""
117
117
Commit a container to an image. Similar to the ``docker commit``
118
118
command.
@@ -123,6 +123,7 @@ def commit(self, container, repository=None, tag=None, message=None,
123
123
tag (str): The tag to push
124
124
message (str): A commit message
125
125
author (str): The name of the author
126
+ pause (bool): Whether to pause the container before committing
126
127
changes (str): Dockerfile instructions to apply while committing
127
128
conf (dict): The configuration for the container. See the
128
129
`Engine API documentation
@@ -139,6 +140,7 @@ def commit(self, container, repository=None, tag=None, message=None,
139
140
'tag' : tag ,
140
141
'comment' : message ,
141
142
'author' : author ,
143
+ 'pause' : pause ,
142
144
'changes' : changes
143
145
}
144
146
u = self ._url ("/commit" )
@@ -317,6 +319,11 @@ def create_container(self, image, command=None, hostname=None, user=None,
317
319
'/var/www': {
318
320
'bind': '/mnt/vol1',
319
321
'mode': 'ro',
322
+ },
323
+ '/autofs/user1': {
324
+ 'bind': '/mnt/vol3',
325
+ 'mode': 'rw',
326
+ 'propagation': 'shared'
320
327
}
321
328
})
322
329
)
@@ -327,10 +334,11 @@ def create_container(self, image, command=None, hostname=None, user=None,
327
334
.. code-block:: python
328
335
329
336
container_id = client.api.create_container(
330
- 'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2'],
337
+ 'busybox', 'ls', volumes=['/mnt/vol1', '/mnt/vol2', '/mnt/vol3' ],
331
338
host_config=client.api.create_host_config(binds=[
332
339
'/home/user1/:/mnt/vol2',
333
340
'/var/www:/mnt/vol1:ro',
341
+ '/autofs/user1:/mnt/vol3:rw,shared',
334
342
])
335
343
)
336
344
@@ -861,8 +869,8 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
861
869
params ['since' ] = since
862
870
else :
863
871
raise errors .InvalidArgument (
864
- 'since value should be datetime or positive int/float, '
865
- ' not {}' . format ( type (since ))
872
+ 'since value should be datetime or positive int/float,'
873
+ f' not { type (since )} '
866
874
)
867
875
868
876
if until is not None :
@@ -878,8 +886,8 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
878
886
params ['until' ] = until
879
887
else :
880
888
raise errors .InvalidArgument (
881
- 'until value should be datetime or positive int/float, '
882
- 'not {}' . format ( type (until ))
889
+ f 'until value should be datetime or positive int/float, '
890
+ f 'not { type (until )} '
883
891
)
884
892
885
893
url = self ._url ("/containers/{0}/logs" , container )
@@ -951,7 +959,7 @@ def port(self, container, private_port):
951
959
return port_settings .get (private_port )
952
960
953
961
for protocol in ['tcp' , 'udp' , 'sctp' ]:
954
- h_ports = port_settings .get (private_port + '/' + protocol )
962
+ h_ports = port_settings .get (f" { private_port } / { protocol } " )
955
963
if h_ports :
956
964
break
957
965
0 commit comments