import docker client = docker.from_env() docker_ps_list = client.containers() length = len(docker_ps_list) print(length) for container in docker_ps_list: print(container)