@@ -22,7 +22,8 @@ def with_env(self, key: str, value: str) -> 'DockerContainer':
22
22
self .env [key ] = value
23
23
return self
24
24
25
- def with_bind_ports (self , container : int , host : int = None ) -> 'DockerContainer' :
25
+ def with_bind_ports (self , container : int ,
26
+ host : int = None ) -> 'DockerContainer' :
26
27
self .ports [container ] = host
27
28
return self
28
29
@@ -33,17 +34,20 @@ def with_exposed_ports(self, *ports) -> 'DockerContainer':
33
34
34
35
def start (self ):
35
36
print ("" )
36
- print ("{} {}" .format (crayons .yellow ("Pulling image" ), crayons .red (self .image )))
37
+ print ("{} {}" .format (crayons .yellow ("Pulling image" ),
38
+ crayons .red (self .image )))
37
39
with blindspin .spinner ():
38
- self ._container = self .get_docker_client ().run (self .image ,
39
- command = self ._command ,
40
- detach = True ,
41
- environment = self .env ,
42
- ports = self .ports ,
43
- name = self ._name ,
44
- volumes = self .volumes )
40
+ docker_client = self .get_docker_client ()
41
+ self ._container = docker_client .run (self .image ,
42
+ command = self ._command ,
43
+ detach = True ,
44
+ environment = self .env ,
45
+ ports = self .ports ,
46
+ name = self ._name ,
47
+ volumes = self .volumes )
45
48
print ("" )
46
- print ("Container started: " , crayons .yellow (self ._container .short_id , bold = True ))
49
+ print ("Container started: " ,
50
+ crayons .yellow (self ._container .short_id , bold = True ))
47
51
return self
48
52
49
53
def stop (self , force = True , delete_volume = True ):
@@ -72,7 +76,8 @@ def with_name(self, name: str) -> 'DockerContainer':
72
76
self ._name = name
73
77
return self
74
78
75
- def with_volume_mapping (self , host : str , container : str , mode : str = 'ro' ) -> 'DockerContainer' :
79
+ def with_volume_mapping (self , host : str , container : str ,
80
+ mode : str = 'ro' ) -> 'DockerContainer' :
76
81
# '/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'}
77
82
mapping = {'bind' : container , 'mode' : mode }
78
83
self .volumes [host ] = mapping
0 commit comments