File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,33 @@ def id(self):
49
49
def name (self ):
50
50
return self .inspect ()["Name" ][1 :] # get rid of slash in front
51
51
52
+ @classmethod
53
+ def client_version (cls ):
54
+ """Docker client version"""
55
+ return cls .version ("{{.Client.Version}}" )
56
+
57
+ @classmethod
58
+ def server_version (cls ):
59
+ """Docker server version"""
60
+ return cls .version ("{{.Server.Version}}" )
61
+
62
+ @classmethod
63
+ def version (cls , format = None ):
64
+ """Docker version_ with an optional format (Go template).
65
+
66
+ >>> host.docker.version()
67
+ Client: Docker Engine - Community
68
+ ...
69
+ >>> host.docker.version("{{.Client.Context}}"))
70
+ default
71
+
72
+ .. _version: https://docs.docker.com/engine/reference/commandline/version/
73
+ """
74
+ cmd = "docker version"
75
+ if format :
76
+ cmd = "{} --format '{}'" .format (cmd , format )
77
+ return cls .check_output (cmd )
78
+
52
79
@classmethod
53
80
def get_containers (cls , ** filters ):
54
81
"""Return a list of containers
You can’t perform that action at this time.
0 commit comments