added python Testskript
This commit is contained in:
11
docker_restapi
Normal file
11
docker_restapi
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Docker engine use a REST API
|
||||||
|
curl -s --unix-socket /var/run/docker.sock http://v1.32/info | jq "."
|
||||||
|
curl -s --unix-socket /var/run/docker.sock http://v1.41/info | jq "."
|
||||||
|
docker image save -o nginx.tar nginx:1.19.3
|
||||||
|
tar tf nginx.tar
|
||||||
|
docker image load -i nginx.tar
|
||||||
|
#docker container export ...
|
||||||
|
#docker image import ...
|
||||||
|
|
||||||
|
# docker api Starten.
|
||||||
|
docker container run -v /var/run/docker.sock:/var/run/docker.sock --rm -t docker docker container ls
|
||||||
105
docker_sheets
Normal file
105
docker_sheets
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
List of Common Docker commands
|
||||||
|
|
||||||
|
This command is used to run a command in a new container.
|
||||||
|
|
||||||
|
$ docker container run
|
||||||
|
|
||||||
|
This command is used to start one or more stopped containers.
|
||||||
|
|
||||||
|
$ docker container start
|
||||||
|
|
||||||
|
This command is used to stop one or more running containers.
|
||||||
|
|
||||||
|
$ docker container stop
|
||||||
|
|
||||||
|
This command is used to restart one or more containers.
|
||||||
|
|
||||||
|
$ docker container restart
|
||||||
|
|
||||||
|
This command is used to remove one or more docker containers.
|
||||||
|
|
||||||
|
$ docker container rm
|
||||||
|
|
||||||
|
This command is used to run a command in a run-time container
|
||||||
|
|
||||||
|
$ docker container exec
|
||||||
|
|
||||||
|
This command is used attach to a running container
|
||||||
|
|
||||||
|
$ docker container attach
|
||||||
|
|
||||||
|
This command is used to fetch all the running containers.
|
||||||
|
|
||||||
|
$ docker container ls
|
||||||
|
|
||||||
|
This command forcefully terminates the container execution.
|
||||||
|
|
||||||
|
$ docker container kill
|
||||||
|
|
||||||
|
This command is used to copy files/folders between a container and the local machine.
|
||||||
|
|
||||||
|
$ docker container cp
|
||||||
|
|
||||||
|
This command is used to rename a container.
|
||||||
|
|
||||||
|
$ docker container rename
|
||||||
|
|
||||||
|
This command is used to fetch the logs of a container.
|
||||||
|
|
||||||
|
$ docker container logs
|
||||||
|
|
||||||
|
This command is used to build an image form a Docker file.
|
||||||
|
|
||||||
|
$ docker build
|
||||||
|
|
||||||
|
This command is used push an image or a repository to a registry.
|
||||||
|
|
||||||
|
$ docker image push
|
||||||
|
|
||||||
|
This command is used pull an image or a repository from a registry.
|
||||||
|
|
||||||
|
$ docker image pull
|
||||||
|
|
||||||
|
This command is used to search the Docker Hub for images
|
||||||
|
|
||||||
|
$ docker search
|
||||||
|
|
||||||
|
This command is used export a container’s file system as a tar archive
|
||||||
|
|
||||||
|
$ docker container export
|
||||||
|
|
||||||
|
This command is used create a new image from a container’s changes
|
||||||
|
|
||||||
|
$ docker container commit
|
||||||
|
|
||||||
|
This command is used to show the history of an image.
|
||||||
|
|
||||||
|
$ docker image history
|
||||||
|
|
||||||
|
This command is used to remove one or more images.
|
||||||
|
|
||||||
|
$ docker image rm
|
||||||
|
|
||||||
|
This command is used to log in to a Docker registry.
|
||||||
|
|
||||||
|
$ docker login
|
||||||
|
|
||||||
|
This command is used to log out from a Docker registry.
|
||||||
|
|
||||||
|
$ docker logout
|
||||||
|
|
||||||
|
This command is used to extract docker version information.
|
||||||
|
|
||||||
|
$ docker version
|
||||||
|
|
||||||
|
This command is used to fetch the real time events from the server.
|
||||||
|
|
||||||
|
$ docker events
|
||||||
|
|
||||||
|
This command is used to manage the Plugins.
|
||||||
|
|
||||||
|
$ docker plugin
|
||||||
|
|
||||||
|
This command is used to manage Docker configuration.
|
||||||
|
|
||||||
|
$ docker config
|
||||||
@@ -2,18 +2,25 @@
|
|||||||
|
|
||||||
import docker
|
import docker
|
||||||
|
|
||||||
client = docker.from_env()
|
#client = docker.from_env()
|
||||||
#print(client.info()["ContainersRunning"])
|
|
||||||
AllImage = client.images.list(all=True)
|
|
||||||
|
|
||||||
def read_all_container():
|
# Mit eval kann ich ein String zum Command ausführen !!!!
|
||||||
|
|
||||||
|
def show_docker_con_img(input):
|
||||||
|
output_list = []
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
AllContainer = client.containers.list(all=True)
|
if input == "images":
|
||||||
low_list= []
|
search_query = "RepoTags"
|
||||||
for con in AllContainer:
|
test = 'client.' + input + '.list(all=True)'
|
||||||
test = str(con).split(":")
|
if input == "containers":
|
||||||
low_list.append(test[1].replace(">", ""))
|
search_query = "Id"
|
||||||
con_dict = {"container" : low_list}
|
test = 'client.' + input + '.list(all=True)'
|
||||||
return con_dict
|
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(read_all_container()["container"])
|
print(show_docker_con_img("containers"))
|
||||||
|
#print(show_docker_con_img("images"))
|
||||||
|
|||||||
Reference in New Issue
Block a user