27 lines
760 B
Python
27 lines
760 B
Python
#! /usr/bin/env python3
|
|
|
|
import docker
|
|
|
|
#client = docker.from_env()
|
|
|
|
# Mit eval kann ich ein String zum Command ausführen !!!!
|
|
|
|
def show_docker_con_img(input):
|
|
output_list = []
|
|
client = docker.from_env()
|
|
if input == "images":
|
|
search_query = "RepoTags"
|
|
test = 'client.' + input + '.list(all=True)'
|
|
if input == "containers":
|
|
search_query = "Id"
|
|
test = 'client.' + input + '.list(all=True)'
|
|
else:
|
|
raise InterruptedError("Die Funktion nutzt nur als input : \n images \n containers")
|
|
for i in eval(test):
|
|
query_Tags = "".join(i.attrs[search_query])
|
|
output_list.append(query_Tags)
|
|
return output_list
|
|
|
|
print(show_docker_con_img("containers"))
|
|
#print(show_docker_con_img("images"))
|