Spaces:
Configuration error
Configuration error
Download openhands/runtime/impl/docker/containers.py from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/runtime/impl/docker/containers.py
- Command line
-
hf download hf://spaces/flyingdarkdev/README/openhands/runtime/impl/docker/containers.py
-
curl -L -o containers.py https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/openhands/runtime/impl/docker/containers.py
551 Bytes
| import docker | |
| def stop_all_containers(prefix: str): | |
| docker_client = docker.from_env() | |
| try: | |
| containers = docker_client.containers.list(all=True) | |
| for container in containers: | |
| try: | |
| if container.name.startswith(prefix): | |
| container.stop() | |
| except docker.errors.APIError: | |
| pass | |
| except docker.errors.NotFound: | |
| pass | |
| except docker.errors.NotFound: # yes, this can happen! | |
| pass | |
| finally: | |
| docker_client.close() | |