27 lines
767 B
Python
Executable File
27 lines
767 B
Python
Executable File
#! /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 str(input) == "images":
|
|
search_query = "RepoTags"
|
|
test = 'client.' + input + '.list(all=False)'
|
|
elif 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"))
|