-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_wrapper.py
25 lines (19 loc) · 748 Bytes
/
docker_wrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import docker
client = docker.from_env()
images = client.images.list()
print("Number of Images in this node are ", len(images))
print("Images are ")
for i, image in enumerate(images):
print(i, image)
containers = client.containers.list()
print("Number of containers running in this node are ", len(containers))
print("Containers are ")
for i, container in enumerate(containers):
print(i, container, container.attrs['Config']['Image'])
def run_container(image="ubuntu", command="echo hello", detach=False):
if detach is False:
out = client.containers.run(image, command)
print(out)
if __name__ == "__main__":
print("enter main")
#run_container("jaglinuxdocker/ubuntu-plus:latest", command="lspci -d 1002:")