Docker python api

Connect to the client
Import docker
Client = docker.from_env ()
Get all containers
Containers = docker.containers.list ("before")
Get all running containers
Containers = docker.containers.list () Default The all parameter prints the container's parameters
For container in containers:
Print conatiner.short_id
Print container.status
Print conatiner.image
Print container.attrs – container configuration

Get a mirror
Container = client.containers.get ("xxx") xxx – the id or name or short_id of the container

Deletion of containers related to the operation of the container
Container.remove ()
Rename the container
Container.rename ()
The container is stopped
Container.stop ()
The forced stop of the container
Container.kill ()
Container start
Container..start ()
Container restart
Container.restart ()

Heads up! This alert needs your attention, but it's not super important.